* Help on program development...
@ 1995-02-21 21:20 Tony Cox
1995-02-22 15:23 ` Greg Lueck Development Environment
1995-02-27 20:36 ` Tim Lucia
0 siblings, 2 replies; 3+ messages in thread
From: Tony Cox @ 1995-02-21 21:20 UTC (permalink / raw)
I am an experienced programmer, but new to Alpha/OSF.
I am currently trying to port an application to OSF, and am having considerable
difficulty in a call to `calloc' which _should_ be very straight forward.
Now, I'm not trying to get people to solve my problem for me, but I would like
a hand in trying to establish the correct _mechanism_ for solving the problem.
That said, here is the problem.
My code is making a call to calloc, like this:-
pb = calloc( 1, 32);
Every time this routine is called, I get the infamous "Segmentation fault".
Running with dbx reveals the following stack frame (which I'm abbreviating)
immediately after the fault in response to the dbx command `where'.
> 0 cartesian_alloc(....)
1 malloc(...)
2 calloc( 0x12003af3c, 0x1, 0x20, 0x20, 0x11ffff0d9)
["..../src/usr/ccs/lib/libc/calloc.c":119, 0x12003fef8]
3 bucketCreate( nHashTableEntries = 4096)
......
7 main( argc=4, argv=0x11ffff868) ["../caget.c":71, 0x12001c128]
(bucketCreate is in my source code, where calloc is called).
I infer from this that (dbx at least) thinks that calloc has been called with
5 parameters, which clearly isn't the case. The function is correctly
prototyped, so simple compilation errors shouldn't be an issue. Replacing the
parameter list by two variables according to the man pages (man 3 calloc)
gives the same result. Interestingly, the routine completes correctly (and as
far as I know, further program execution continues correctly) if the second
parameter is > 88(decimal), although it fails for any value <= 88.
Now, running the program under decladebug gives the same segmentation fault,
but the `where' command reveals a different stack frame...
>0 ... in cartesian_alloc()
1 malloc()
2 calloc() ......./src/usr/ccs/lib/libc/calloc.c:119
3 bucketCreate( nHashTableEntries = 4096)
4 ca_os_independent_init() ../access.c:573
.......
7 main( argc=4, argv=0x11ffff868) ../caget.c:71
It seems now that decladebug believes that the routines are called without
any arguements at all!
The only other clue I have is that in response to the `where' command,
decladebug gives 4 errors in (presumably) trying to sort out the symbols
for bucketCreate's caller. I get messages of the form:-
Unexpected symbol type Param in field list for pformat in file #36 ../access.c
What is also odd is that I have managed to get this code (in an earlier
version) running without any errors of this type. It is only since I got the
most recent version from my colleagues that this has all started to come apart!
This would seem to rule out a compiler bug.
Does anyone know what could possibly be causing this? Could it be that the
parameter list for calloc is being maintained in an area of storage which is
now being overwitten some other routine?
In a nutshell, where the hell do I go from here?????
Tony Cox
--------------------------------------------------------------------------------
Dr Anthony D Cox
Computer Systems Specialist
Stanford Synchrotron Radiation Laboratory
Stanford Linear Accelerator Center
MS 69, Box 4349
Stanford CA 94305
tcox@ssrl01.slac.stanford.edu
--------------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Help on program development...
1995-02-21 21:20 Help on program development Tony Cox
@ 1995-02-22 15:23 ` Greg Lueck Development Environment
1995-02-27 20:36 ` Tim Lucia
1 sibling, 0 replies; 3+ messages in thread
From: Greg Lueck Development Environment @ 1995-02-22 15:23 UTC (permalink / raw)
Tony,
The unusual parameter information you see in the stack backtrace almost
certainly has nothing to do with the bug you are tracking down. The routine
calloc() exists in the system library and the system libraries are not
compiled with debug information. Thus, there is not enough information for
the debuggers to tell what parameters were passed to calloc(). Dbx (I believe)
prints out the contents of five stack locations that may, or may not contain
useful parameter information. It's usually best to ignore this information.
Decladebug simply does not print any parameter information when it doesn't
know the parameters.
Segmentation faults in the memory allocation routines (malloc, calloc, free,
realloc) are usually a delayed reaction to a previous bug in your application.
Doing illegal things like free'ing something that was never allocated or
writing beyond the end of an allocated buffer can cause the internal data
structures in the memory allocation routines to become corrupt. This usually
results in a segmentation fault later on when you call malloc(), calloc(),
free(), or realloc().
There are tools that can help you debug such a problem. There is a tool
called Third Degree on OSF/1 V3.0 and later which is designed to locate
memory allocation errors like this. The Third Degree tool is layered on
another tool called Atom. You get both tools when you install the ATMBASE300
subset from the base operating system CD. There is documentation describing
Third Degree in /usr/lib/atom/doc/3rd.ps. There is also a manpage for the
Third Degree tool in /usr/lib/atom/man/man1/third.1.
--
-------------------------------------------------------------------------------
Greg Lueck Opinions expressed herein are my own.
lueck@zk3.dec.com
-------------------------------------------------------------------------------
--
-------------------------------------------------------------------------------
Greg Lueck Opinions expressed herein are my own.
lueck@zk3.dec.com
-------------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Help on program development...
1995-02-21 21:20 Help on program development Tony Cox
1995-02-22 15:23 ` Greg Lueck Development Environment
@ 1995-02-27 20:36 ` Tim Lucia
1 sibling, 0 replies; 3+ messages in thread
From: Tim Lucia @ 1995-02-27 20:36 UTC (permalink / raw)
In article <1995Feb21.132048.1@ssrl01>, tcox@ssrl01.slac.stanford.edu (Tony Cox) writes:
|>I am an experienced programmer, but new to Alpha/OSF.
|>
|>I am currently trying to port an application to OSF, and am having considerable
|>difficulty in a call to `calloc' which _should_ be very straight forward.
|>
|>Now, I'm not trying to get people to solve my problem for me, but I would like
|>a hand in trying to establish the correct _mechanism_ for solving the problem.
|>
|>That said, here is the problem.
|>My code is making a call to calloc, like this:-
|>
|> pb = calloc( 1, 32);
|>
|>Every time this routine is called, I get the infamous "Segmentation fault".
|>
|>Running with dbx reveals the following stack frame (which I'm abbreviating)
|>immediately after the fault in response to the dbx command `where'.
|>
|>> 0 cartesian_alloc(....)
|> 1 malloc(...)
|> 2 calloc( 0x12003af3c, 0x1, 0x20, 0x20, 0x11ffff0d9)
|> ["..../src/usr/ccs/lib/libc/calloc.c":119, 0x12003fef8]
|> 3 bucketCreate( nHashTableEntries = 4096)
|> ......
|> 7 main( argc=4, argv=0x11ffff868) ["../caget.c":71, 0x12001c128]
|>
|>(bucketCreate is in my source code, where calloc is called).
|>
|>
|>I infer from this that (dbx at least) thinks that calloc has been called with
|>5 parameters, which clearly isn't the case. The function is correctly
|>prototyped, so simple compilation errors shouldn't be an issue. Replacing the
|>parameter list by two variables according to the man pages (man 3 calloc)
|>gives the same result. Interestingly, the routine completes correctly (and as
|>far as I know, further program execution continues correctly) if the second
|>parameter is > 88(decimal), although it fails for any value <= 88.
|>
If all other things are equal at the point of failure, then the fact that
the size > 88 does not break and size <= 88 does implies the free list is
trampled, probably by free()ing something you did not allocate or in some
other way trampling on bookkeeping data structures in the heap management.
I would guess that '88' is the upper-limit of a block size, i.e., allocations
bigger than 88 end up coming from a different free list.
--
Timothy J. Lucia - DECladebug Email: lucia@zko.dec.com
Digital Equipment Corporation Phone: 603.881.2615
110 Spitbrook Road ZKO2-3/K06 Fax: 603.881.0120
Nashua, NH USA 03062-2698 C++ Programmers do it with class
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1995-02-27 20:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-02-21 21:20 Help on program development Tony Cox
1995-02-22 15:23 ` Greg Lueck Development Environment
1995-02-27 20:36 ` Tim Lucia
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox