leocheang422 / exceptions4c

Automatically exported from code.google.com/p/exceptions4c
0 stars 0 forks source link

e4c calls exit() from a function registered with atexit() #10

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
On line 2606 of e4c.c, exit() is called within the function 
_e4c_library_finalize, which is registered as a finalizer by atexit(). From the 
man page for atexit(3):

    POSIX.1-2001 says that the result of calling exit(3) more than once
    (i.e., calling exit(3) within a function registered using atexit()) is
    undefined. On some systems (but not Linux), this can result in an infinite
    recursion; portable programs should not invoke exit(3) inside a function
    registered using atexit().

While I'm not sure if this is a real problem on any major OS, I'm worried that 
it may be a portability concern.

Original issue reported on code.google.com by ImJa...@gmail.com on 18 Jul 2013 at 12:39

GoogleCodeExporter commented 8 years ago
You're absolutely right.

I've done my research too and found that, as you say, a function that is 
registered as an exit handler by `atexit()` must exit by returning, and not in 
any other manner.

The purpose of the `exit` call was to warn the programmer about a fatal library 
misuse, by forcing the return value of the program to `EXIT_FAILURE`. But now I 
know I really shouldn't be doing that; I'll fix it as soon as possible.

Thank you very much for reporting :)

Original comment by guillermocalvo on 18 Jul 2013 at 4:03

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r417.

Original comment by guillermocalvo on 18 Jul 2013 at 5:11