public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/859] New: When running under SCHED_FIFO, fork + malloc = infinite loop
@ 2005-04-18 19:53 david dot carlton at sun dot com
  2005-04-18 21:15 ` [Bug libc/859] " david dot carlton at sun dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: david dot carlton at sun dot com @ 2005-04-18 19:53 UTC (permalink / raw)
  To: glibc-bugs

We have software that runs under SCHED_FIFO; if one of the threads
calls fork() while another thread wants to malloc(), the mallocing
thread gets stuck in an infinite loop.  Some backtraces:

The mallocing thread:

(gdb) bt
#0  0x4019bc7d in pthread_mutex_trylock () from /lib/i686/libpthread.so.0
#1  0x42079dd9 in arena_get2 () from /lib/i686/libc.so.6
#2  0x4207bc95 in calloc () from /lib/i686/libc.so.6

The forking thread:

(gdb) bt
#0  0x4207977e in ptmalloc_lock_all () from /lib/i686/libc.so.6
#1  0x4019c4d2 in fork () from /lib/i686/libpthread.so.0

As far as I can tell, the forking thread locks all the mutexes, then
a context switch is allowed (to let the newly forked process run,
I suppose?), then when a thread from the forking process is next allowed to
run, a thread other than the forking thread happens to be chosen.  And
that thread runs into the following comment from arena.c:

  /* if not even the list_lock can be obtained, try again.  this can
     happen during `atfork', or for example on systems where thread
     creation makes it temporarily impossible to obtain _any_
     locks. */

And, in SCHED_FIFO mode, no context switch can happen while trying
again, so it locks up.

Obviously using SCHED_FIFO is a delicate area, but this still seems
unfortunate.  Any suggestions for ways to work around this?  (I guess
I could modify the code in malloc to do a sched_yield if it goes through
that loop too many times.)  Do newer glibc versions exhibit the same
behavior?  (We'll upgrade to a newer glibc in a few months, I hope.)

-- 
           Summary: When running under SCHED_FIFO, fork + malloc = infinite
                    loop
           Product: glibc
           Version: 2.2.5
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: gotom at debian dot or dot jp
        ReportedBy: david dot carlton at sun dot com
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://sources.redhat.com/bugzilla/show_bug.cgi?id=859

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug libc/859] When running under SCHED_FIFO, fork + malloc = infinite loop
  2005-04-18 19:53 [Bug libc/859] New: When running under SCHED_FIFO, fork + malloc = infinite loop david dot carlton at sun dot com
@ 2005-04-18 21:15 ` david dot carlton at sun dot com
  2005-09-27  5:49 ` drepper at redhat dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: david dot carlton at sun dot com @ 2005-04-18 21:15 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From david dot carlton at sun dot com  2005-04-18 21:15 -------
I guess this must be fixed by

http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/malloc/arena.c.diff?r1=1.12&r2=1.13&cvsroot=glibc&only_with_tag=MAIN&f=h

It looks like the patch won't quite apply cleanly to the 2.2.5 sources,
the differences being the atomic_write_barrier() and the error checking
on mutex_lock(&a->mutex).  Should I worry about that or not?

-- 


http://sources.redhat.com/bugzilla/show_bug.cgi?id=859

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug libc/859] When running under SCHED_FIFO, fork + malloc = infinite loop
  2005-04-18 19:53 [Bug libc/859] New: When running under SCHED_FIFO, fork + malloc = infinite loop david dot carlton at sun dot com
  2005-04-18 21:15 ` [Bug libc/859] " david dot carlton at sun dot com
@ 2005-09-27  5:49 ` drepper at redhat dot com
  2005-09-27 15:39 ` david dot carlton at sun dot com
  2005-10-16  7:56 ` drepper at redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: drepper at redhat dot com @ 2005-09-27  5:49 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2005-09-27 05:49 -------
I don't know how to reproduce it.   If yo can do it (and describe it) or close
the bug.  And don't bother testing anything but the mainline sources.  The most
recent changes will soon be the Fedora Core rawhide code base.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug libc/859] When running under SCHED_FIFO, fork + malloc = infinite loop
  2005-04-18 19:53 [Bug libc/859] New: When running under SCHED_FIFO, fork + malloc = infinite loop david dot carlton at sun dot com
  2005-04-18 21:15 ` [Bug libc/859] " david dot carlton at sun dot com
  2005-09-27  5:49 ` drepper at redhat dot com
@ 2005-09-27 15:39 ` david dot carlton at sun dot com
  2005-10-16  7:56 ` drepper at redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: david dot carlton at sun dot com @ 2005-09-27 15:39 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From david dot carlton at sun dot com  2005-09-27 15:39 -------
I'm pretty sure it's been fixed in mainline.

-- 


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug libc/859] When running under SCHED_FIFO, fork + malloc = infinite loop
  2005-04-18 19:53 [Bug libc/859] New: When running under SCHED_FIFO, fork + malloc = infinite loop david dot carlton at sun dot com
                   ` (2 preceding siblings ...)
  2005-09-27 15:39 ` david dot carlton at sun dot com
@ 2005-10-16  7:56 ` drepper at redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: drepper at redhat dot com @ 2005-10-16  7:56 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2005-10-16 07:55 -------
If it's fixed there's no reason to keep the bug open.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |FIXED


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

end of thread, other threads:[~2005-10-16  7:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-18 19:53 [Bug libc/859] New: When running under SCHED_FIFO, fork + malloc = infinite loop david dot carlton at sun dot com
2005-04-18 21:15 ` [Bug libc/859] " david dot carlton at sun dot com
2005-09-27  5:49 ` drepper at redhat dot com
2005-09-27 15:39 ` david dot carlton at sun dot com
2005-10-16  7:56 ` drepper 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).