From: lucia@savvy.zko.dec.com (Tim Lucia)
Subject: Re: Help on program development...
Date: 27 Feb 1995 20:36:07 GMT [thread overview]
Message-ID: <3itd3n$1si@jac.zko.dec.com> (raw)
In-Reply-To: 1995Feb21.132048.1@ssrl01
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
prev parent reply other threads:[~1995-02-27 20:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox