[H-GEN] malloc() causing a segfault
Martin Pool
mbp at linuxcare.com.au
Wed Aug 30 23:44:59 EDT 2000
On Thu, Aug 31, 2000 at 01:35:38PM +1000, Byron Ellacott wrote:
> [ Humbug *General* list - semi-serious discussions about Humbug and ]
> [ Unix-related topics. Please observe the list's charter. ]
>
> On Thu, 31 Aug 2000, Nikolai Lusan wrote:
>
> > The odd this is this code is part of a proccedure that can run a hundred
> > time with no problems, the exact fault occurs with the malloc and a
> > debugger gives "0x40065c06 in free () from /lib/libc.so.6". Personally I
> > have no Idea why this is happening, and it has been eating me all
> > morning.
>
> Without knowing what is in your <SNIP> it's hard to give guidance.
>
> 1) check the return value of malloc; if it's NULL, the allocation failed
> and you should abort
> 2) You may be overwriting the value of tmp, or through a bounds problem,
> overwriting meta information about the allocated block, causing free()
> to fail.
> 3) A called function may be doing something wrong resulting in the free
> memory list becoming corrupted.
A relatively easy way to find out which of these is the case is to
link with the ElectricFence library. This will make the program
(probably) crash immediately the error occurs, rather than later on in
free(). This should make the problem much more obvious.
>
--
Martin Pool, Linuxcare, Inc.
+61 2 6262 8990
mbp at linuxcare.com, http://www.linuxcare.com/
Linuxcare. Support for the revolution.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL: <http://lists.humbug.org.au/pipermail/general/attachments/20000831/1def4a45/attachment.sig>
More information about the General
mailing list