public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "sdh4 at iastate dot edu" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libgomp/52303] New: libgomp leaves threads lying around that cause trouble if the program is later fork()'d Date: Sat, 18 Feb 2012 00:34:00 -0000 [thread overview] Message-ID: <bug-52303-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52303 Bug #: 52303 Summary: libgomp leaves threads lying around that cause trouble if the program is later fork()'d Classification: Unclassified Product: gcc Version: 4.6.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgomp AssignedTo: unassigned@gcc.gnu.org ReportedBy: sdh4@iastate.edu Libgomp creates a thread pool on each thread with a parallel section. This pool silently hangs around even when no longer in the parallel section. If the process is later fork()'d and the child process subsequently enters a parallel section, the child process will deadlock waiting on threads that do not exist (fork() does not duplicate threads). The pthreads library provides a mechanism to avoid problems such as this. Specifically (quoting the manpage for pthread_atfork()): The pthread_atfork() function provides multi-threaded libraries with a means to protect themselves from innocent application programs that call fork(), and it provides multi-threaded application programs with a standard mechanism for protecting themselves from fork() calls in a library routine or the application itself. libgomp should call pthread_atfork() with team.c/gomp_free_thread() (or a wrapper) as the "prepare" parameter so as to destroy the threadpool before fork() is executed. The problem can be worked around by placing the parallel section in a sub-thread that exits before fork() is called. libgomp automatically destroys the thread-pool of a thread that exits.
next reply other threads:[~2012-02-18 0:19 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-02-18 0:34 sdh4 at iastate dot edu [this message] 2012-02-18 10:05 ` [Bug libgomp/52303] " jakub at gcc dot gnu.org 2012-02-18 23:19 ` sdh4 at iastate dot edu 2012-02-19 18:50 ` jakub at gcc dot gnu.org 2013-09-05 9:47 ` olivier.grisel at ensta dot org 2013-09-05 10:06 ` olivier.grisel at ensta dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-52303-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).