[H-GEN] malloc() causing a segfault

Byron Ellacott bje at apnic.net
Wed Aug 30 23:35:38 EDT 2000


[ 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.

-- 
bje


--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.



More information about the General mailing list