diff mbox

[Hurd] Fix hang on fork

Message ID 20140827230625.GW3343@type.youpi.perso.aquilenet.fr
State New
Headers show

Commit Message

Samuel Thibault Aug. 27, 2014, 11:06 p.m. UTC
If e.g. a signal is being received while we are running fork(), the signal
thread may be having our SS lock when we make the space copy, and thus in the
child we can not take the SS lock any more.

* sysdeps/mach/hurd/fork.c (__fork): Lock SS->lock around __proc_dostop() call.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

---
 sysdeps/mach/hurd/fork.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Samuel Thibault Aug. 27, 2014, 11:07 p.m. UTC | #1
(Building the petsc package consistently reproduces the issue several
times during the build, while I could build the package twice without
any issue with the patch applied).

Samuel
Roland McGrath Aug. 28, 2014, 6:21 p.m. UTC | #2
Fix comment formatting, put space before paren, write a ChangeLog entry.
diff mbox

Patch

--- a/sysdeps/mach/hurd/fork.c
+++ b/sysdeps/mach/hurd/fork.c
@@ -130,9 +130,13 @@  __fork (void)
       ports_locked = 1;
 
 
+      /* Keep our SS locked while stopping other threads, so they don't get a
+       * chance to be having it locked in the copied space.  */
+      __spin_lock(&ss->lock);
       /* Stop all other threads while copying the address space,
 	 so nothing changes.  */
       err = __proc_dostop (_hurd_ports[INIT_PORT_PROC].port, ss->thread);
+      __spin_unlock(&ss->lock);
       if (!err)
 	{
 	  stopped = 1;