public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/14333] New: Fix the race between atexit() and exit()
@ 2012-07-06  1:53 penght at cn dot fujitsu.com
  2012-10-11 14:17 ` [Bug libc/14333] " carlos_odonell at mentor dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: penght at cn dot fujitsu.com @ 2012-07-06  1:53 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14333

             Bug #: 14333
           Summary: Fix the race between atexit() and exit()
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: unassigned@sourceware.org
        ReportedBy: penght@cn.fujitsu.com
                CC: carlos@systemhalted.org, drepper.fsp@gmail.com
    Classification: Unclassified


Created attachment 6511
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6511
The Patch can fix the race betweent atexit() and exit()

exit() uses global variable __exit_funcs indirectly, which are not protected.
It is not safe in multithread circumstance.

When call exit() and atexit() simultaneously in multithread circumstance,
the following case will cause unsafe.
The case has main process A and thread B.

a. thread B call atexit()
b. process A call exit() to traverse the __exit_funcs list
c. thread B call calloc() to create a new entry p, and next to listp:
   p->next = *listp;
d. process A modify listp to cur's next, then free cur:
   *listp = cur->next;
e. thread B modify listp to p:
   *listp = p;
f. when get f, the f is undefined:
   const struct exit_function *const f =
     &cur->fns[--cur->idx];
g. programme may be Segmentation fault

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-06-25 10:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-06  1:53 [Bug libc/14333] New: Fix the race between atexit() and exit() penght at cn dot fujitsu.com
2012-10-11 14:17 ` [Bug libc/14333] " carlos_odonell at mentor dot com
2012-10-12  2:40 ` penght at cn dot fujitsu.com
2012-10-12  2:41 ` penght at cn dot fujitsu.com
2012-10-18  3:10 ` siddhesh at redhat dot com
2012-10-22  7:53 ` penght at cn dot fujitsu.com
2012-12-03 23:59 ` carlos at systemhalted dot org
2014-06-18  4:27 ` fweimer at redhat dot com
2014-06-25 10:53 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).