Patchwork [committed] Fix futex_wait in libgomp (PR libgomp/47731)

login
register
mail settings
Submitter Jakub Jelinek
Date Feb. 14, 2011, 3:12 p.m.
Message ID <20110214151217.GK30899@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/83088/
State New
Headers show

Comments

Jakub Jelinek - Feb. 14, 2011, 3:12 p.m.
Hi!

The arm futex.h version is broken, because it passed random value as
timeout pointer to FUTEX_WAIT syscall, which means it could fail with
EFAULT, or have some random timeout, and, as it has been added to the
generic config/linux/ directory and config/linux/wait.h includes it
through #include "futex.h" instead of #include <futex.h>, suddenly the
broken generic version has been used on all linux targets.

Both issues fixed thusly, bootstrapped/regtested on x86_64-linux and
i686-linux, committed to trunk.

2011-02-14  Jakub Jelinek  <jakub@redhat.com>

	PR libgomp/47731
	* config/linux/futex.h (futex_wait): Pass NULL as timeout argument
	to FUTEX_WAIT futex syscall.
	* config/linux/wait.h: Include <futex.h> instead of "futex.h".


	Jakub

Patch

--- libgomp/config/linux/futex.h.jj	2010-10-08 12:01:17.000000000 +0200
+++ libgomp/config/linux/futex.h	2011-02-14 10:35:45.652545572 +0100
@@ -1,4 +1,4 @@ 
-/* Copyright (C) 2010 Free Software Foundation, Inc.
+/* Copyright (C) 2010, 2011 Free Software Foundation, Inc.
    Contributed by ARM Ltd.
 
    This file is part of the GNU OpenMP Library (libgomp).
@@ -41,12 +41,12 @@ 
 static inline void
 futex_wait (int *addr, int val)
 {
-  long err = syscall (SYS_futex, addr, gomp_futex_wait, val);
+  long err = syscall (SYS_futex, addr, gomp_futex_wait, val, NULL);
   if (__builtin_expect (err == -ENOSYS, 0))
     {
       gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
       gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
-      syscall (SYS_futex, addr, gomp_futex_wait, val);
+      syscall (SYS_futex, addr, gomp_futex_wait, val, NULL);
     }
 }
 
--- libgomp/config/linux/wait.h.jj	2010-06-11 11:00:13.000000000 +0200
+++ libgomp/config/linux/wait.h	2011-02-14 10:40:54.693670634 +0100
@@ -1,4 +1,4 @@ 
-/* Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc.
    Contributed by Jakub Jelinek <jakub@redhat.com>.
 
    This file is part of the GNU OpenMP Library (libgomp).
@@ -42,7 +42,7 @@ 
 
 extern long int gomp_futex_wait, gomp_futex_wake;
 
-#include "futex.h"
+#include <futex.h>
 
 static inline void do_wait (int *addr, int val)
 {