From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,46fb2397c46d4608 X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1995-02-27 12:36:07 PST Path: nntp.gmd.de!newsserver.jvnc.net!news.cac.psu.edu!news.pop.psu.edu!hudson.lm.com!godot.cc.duq.edu!news.duke.edu!news.mathworks.com!newshost.marcam.com!zip.eecs.umich.edu!caen!crl.dec.com!crl.dec.com!jac.zko.dec.com!savvy.zko.dec.com!lucia From: lucia@savvy.zko.dec.com (Tim Lucia) Newsgroups: comp.unix.osf.osf1 Subject: Re: Help on program development... Date: 27 Feb 1995 20:36:07 GMT Organization: Digital Equipment Corporation Distribution: world Message-ID: <3itd3n$1si@jac.zko.dec.com> References: <1995Feb21.132048.1@ssrl01> Reply-To: lucia@savvy.zko.dec.com (Tim Lucia) NNTP-Posting-Host: savvy.zko.dec.com X-Newsreader: mxrn 6.18-28 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