From: hari@kaa.informatik.rwth-aachen.de (Harald Dunkel) Subject: How to get an infinite loop using exit() Date: 1 Mar 1993 13:59:49 GMT
Hello, Linuxers.
Here is an interesting problem: I have ported the debug_malloc
library (1.14) to Linux. It's a replacement for malloc(), free(),
strcpy(), memcpy(), etc. When I tried to run the included test programs
I've got an infinite loop at the end of the testerr program. Using
libdbmalloc testerr allocates several memory blocks and destroys the
malloc frame of some of them to force an error message and to exit().
When you run 'nm /lib/libc.a' you may guess what has happened: exit()
calls malloc(), we get a new error message from libdbmalloc's malloc(),
it calls exit(), exit() calls malloc() and so forth.
So what can be done? Should exit() return to the calling function if
called the second time? What happens, if a function installed with
atexit() calls exit()? I think exit() should contain a local static
flag and should use longjmp() to jump to the first call of exit() when
called the second time. But that's only an idea, there may be other
solutions.
Harri