malloc and free
hi
routine xyz uses malloc and free functions. it gives accurate and correct result if called once.
but if the function is called in a loop N number of times then probably it gives segmentation fault.
what is the reason? can any body guess or test code is needed?
thanks
ankit jain
________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html
Quoted 8 lines · you
hi
routine xyz uses malloc and free functions. it gives accurate and correct result if called once.
but if the function is called in a loop N number of times then probably it gives segmentation fault.
Quoted 6 lines
what is the reason? can any body guess or test code is needed?
thanks
ankit jain
A common cause of failure in the malloc/free routines is memory corruption. The trick about memory corruption and buffer overflows is that they work sometimes/most of the time. Perhaps you are doing out-of-bounds reading or (gak!) writing with the memory. Try running it under valgrind to see if this is the case.
Also, although routine xyz may not corrupt the memory perhaps something else in your program is? Writing in strange places confuses libc and can result in a segfault in places that can be quite far away from the original spot of corruption.
----------------------------------------
--EB
Quoted 4 lines
All is fine except that I can reliably "oops" it simply by trying to read from
/proc/apm(e.g. cat/proc/apm).
oops output and ksymoops-2.3.4 output is attached.
Is there anything else I can contribute?
The latitude and longtitude of the bios writers current position, and a ballistic missile.
--Alan Cox LKML-December 08,2000
----------------------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html