This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 468440 - atexit() hooks are not called on exec()
atexit() hooks are not called on exec()
Product: Fedora
Classification: Fedora
Component: man-pages (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Ivana Varekova
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2008-10-24 14:36 EDT by Andrew Zabolotny
Modified: 2008-10-30 08:35 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2008-10-30 04:50:26 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
Sourceware 6982 None None None Never

  None (edit)
Description Andrew Zabolotny 2008-10-24 14:36:26 EDT
Description of problem:

"man 3 exit" says, amongst other:

The  exit()  function  causes  normal process termination and the value of status & 0377 is returned to the parent (see wait(2)).

All functions registered with atexit(3) and on_exit(3) are called, in  the reverse  order  of  their  registration.

However, the atexit() hooks are never called if you invoke any of the exec*() functions.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Copy the example from 'man 3 atexit' to test.c
2. Modify it so that instead of "exit(EXIT_SUCCESS)" at the end we have, for example:

execl ("/bin/ls", "ls");

3. Compile and run the example
Actual results:

$ ./a.out 
ATEXIT_MAX = 2147483647
a.out  test.c

Expected results:

$ ./a.out 
ATEXIT_MAX = 2147483647
That was all, folks
a.out  test.c

Additional info:
I think it is a serious bug as it does not allow applications that rely on it to cleanup things that won't automatically cleanup during a normal process destruction.
Comment 1 Andrew Zabolotny 2008-10-24 14:52:36 EDT
I tried on a micro linux-from-scratch variant I have running here in a virtual machine, and the bug is still there, so it's really a upstream bug.

I have copied the report to the bugzilla recommended on glibc homepage, and added a link to that bugzilla.
Comment 2 Andrew Zabolotny 2008-10-24 15:09:37 EDT
I was told by Ulrich Drepper that this is behaviour is conformant to standards.

I found in the "The Open Group Base Specifications issue 6" the page related to exec() here:

The only quote mentioning atexit is:

<<After a successful call to any of the exec functions, any functions previously registered by atexit() or pthread_atfork() are no longer registered.>>

This is somehow vague, but anyway I think this can be re-classified as a bug in the man page. FreeBSD and Solaris man pages just repeat the same quote from standard.

Changing target package to man-pages-2.78-2.fc9.noarch.
Comment 3 Ivana Varekova 2008-10-30 04:50:26 EDT
The description details from which results the fact - the atexit stuff is not called before the execl call starts - are on execve page (there is link from execl page): 

"All process attributes are preserved during an execve(), except the following:
*  Exit handlers are not preserved (atexit(3), on_exit(3)).

It seems for me to be sufficient info so I think there is no need to add another notice about it.
Comment 4 Andrew Zabolotny 2008-10-30 08:35:28 EDT
Indeed, there's a note on execve() page.

I do not insist, but I think it would be helpful to note this on exec page as well. And even emphasize that the handlers are not called, not just "not preserved". Maybe I don't understand it well, but "handlers are not preserved" and "handlers are not called and not preserved" sound a bit different to me.

Anyway, this bug can be closed I think.

Note You need to log in before you can comment on or make changes to this bug.