|
From: <sv...@va...> - 2011-07-29 06:35:11
|
Author: bart
Date: 2011-07-29 07:30:23 +0100 (Fri, 29 Jul 2011)
New Revision: 11937
Log:
drd: Remove a too strict assert() statement
Modified:
trunk/drd/drd_pthread_intercepts.c
Modified: trunk/drd/drd_pthread_intercepts.c
===================================================================
--- trunk/drd/drd_pthread_intercepts.c 2011-07-29 06:12:51 UTC (rev 11936)
+++ trunk/drd/drd_pthread_intercepts.c 2011-07-29 06:30:23 UTC (rev 11937)
@@ -196,12 +196,10 @@
while (sema->counter == 0) {
#if defined(__linux__) && defined(__NR_futex)
if (syscall(__NR_futex, (UWord)&sema->counter,
- FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0) == 0) {
+ FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0) == 0)
res = 0;
- } else {
+ else
res = errno;
- assert(res == EWOULDBLOCK || res == ENOSYS);
- }
#endif
/*
* Invoke sched_yield() on non-Linux systems, if the futex syscall has
@@ -209,7 +207,7 @@
* where __NR_futex is defined and is run on a Linux system that does
* not support the futex syscall.
*/
- if (res == ENOSYS)
+ if (res != 0 && res != EWOULDBLOCK)
sched_yield();
}
sema->counter--;
|
|
From: Christian B. <bor...@de...> - 2011-07-29 06:48:30
|
> res = errno; > - assert(res == EWOULDBLOCK || res == ENOSYS); > - } Thanks. But isnt there another problem? errno is not set by the valgrind internal syscall variant (coregrind/m_syscall.c), so the value of res is random (or contains an implementation defined value). Christian |
|
From: Bart V. A. <bva...@ac...> - 2011-07-29 06:54:06
|
On Fri, Jul 29, 2011 at 8:48 AM, Christian Borntraeger < bor...@de...> wrote: > > res = errno; > > - assert(res == EWOULDBLOCK || res == ENOSYS); > > - } > > Thanks. But isnt there another problem? errno is not set by the valgrind > internal syscall variant (coregrind/m_syscall.c), so the value of res > is random (or contains an implementation defined value). > The code in drd_pthread_intercepts.c is client code so the syscall() invocation in that source file invokes the glibc syscall() function and not the implementation in coregrind/m_syscall.c. Although I don't know exactly what went wrong in the sless390 nightly build, there is another reason I chose to remove the assert() statement: it is possible that Valgrind is built on a system where FUTEX_PRIVATE_FLAG is defined but the kernel does not support that flag. In that case errno will have another value than EWOULDBLOCK or ENOSYS. Bart. |
|
From: Christian B. <bor...@de...> - 2011-07-29 07:59:18
|
On 29/07/11 08:48, Christian Borntraeger wrote: >> res = errno; >> - assert(res == EWOULDBLOCK || res == ENOSYS); >> - } > > Thanks. But isnt there another problem? errno is not set by the valgrind > internal syscall variant (coregrind/m_syscall.c), so the value of res > is random (or contains an implementation defined value). Ah, I see. this is client context. So yes, this should be ok. |