From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,46fb2397c46d4608,start X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1995-02-21 13:20:48 PST Path: nntp.gmd.de!newsserver.jvnc.net!howland.reston.ans.net!news.cac.psu.edu!news.pop.psu.edu!hudson.lm.com!godot.cc.duq.edu!news.duke.edu!news.mathworks.com!uunet!in1.uu.net!kithrup.com!news.Stanford.EDU!morrow.stanford.edu!ssrl01!tcox From: tcox@ssrl01.slac.stanford.edu (Tony Cox) Newsgroups: comp.unix.osf.osf1 Subject: Help on program development... Date: 21 Feb 95 13:20:48 -0800 Organization: Stanford University Message-ID: <1995Feb21.132048.1@ssrl01> NNTP-Posting-Host: ssrl01.slac.stanford.edu 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 --------------------------------------------------------------------------------