This is the mail archive of the libc-ports@sources.redhat.com mailing list for the libc-ports project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch][RFC] ARM NPTL lll_futex_wake_unlock() issue


Hi all,

I am using glibc-2.7 and found an issue regarding 
ARM NPTL lll_futex_wake_unlock(), which is called by pthread_cond_signal().

ARM NPTL lll_futex_wake_unlock() source code is as follows.
This function should return zero if success

[glibc-ports-2.7/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h]

(snip)

   117  /* Returns non-zero if error happened, zero if success.  */
   118  #define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2, private) \
   119    ({                                                                          \
   120      INTERNAL_SYSCALL_DECL (__err);                                            \
   121      long int __ret;                                                           \
   122      __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp),                      \
   123                                __lll_private_flag (FUTEX_WAKE_OP, private),    \
   124                                (nr_wake), (nr_wake2), (futexp2),               \
   125                                FUTEX_OP_CLEAR_WAKE_IF_GT_ONE);                 \
   126      __ret;                                                                    \
   127    })
   128

But the above ARM implementation does *NOT* return zero if success, I suppose.
Because futex system call at line 122 returns the number of processes 
woken up.

lll_futex_requeue(), which is called by pthread_cond_broadcast(), also
has the same issue.

I think these macros can be fixed as follows 
like other architecture's source code.
ex) glibc-ports-2.7/sysdeps/unix/sysv/linux/mips/nptl/lowlevellock.h


Could you please give me some comments??

Best Regards,
Ryosei Takagi




Index: glibc-2.7/glibc-ports-2.7/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h
===================================================================
--- glibc-2.7.orig/glibc-ports-2.7/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h
+++ glibc-2.7/glibc-ports-2.7/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h
@@ -110,7 +110,7 @@
     __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp),                     \
                              __lll_private_flag (FUTEX_CMP_REQUEUE, private),\
                              (nr_wake), (nr_move), (mutex), (val));          \
-    __ret;                                                                   \
+    INTERNAL_SYSCALL_ERROR_P (__ret, __err);                                 \
   })


@@ -123,7 +123,7 @@
                              __lll_private_flag (FUTEX_WAKE_OP, private),    \
                              (nr_wake), (nr_wake2), (futexp2),               \
                              FUTEX_OP_CLEAR_WAKE_IF_GT_ONE);                 \
-    __ret;                                                                   \
+    INTERNAL_SYSCALL_ERROR_P (__ret, __err);                                 \
   })


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]