Hi Leonid,
Leonid Lisovskiy wrote,
Althought, it is undefined behavior, there is no
reason for segfault.
Signed-off-by: Leonid Lisovskiy <lly.dev(a)gmail.com>
---
libpthread/linuxthreads/mutex.c | 3 ++-
test/pthread/ex8-mtx-odd.c | 56 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+), 1 deletion(-)
create mode 100644 test/pthread/ex8-mtx-odd.c
diff --git a/libpthread/linuxthreads/mutex.c b/libpthread/linuxthreads/mutex.c
index 8908414..8cb779b 100644
--- a/libpthread/linuxthreads/mutex.c
+++ b/libpthread/linuxthreads/mutex.c
@@ -171,7 +171,8 @@ int attribute_hidden __pthread_mutex_unlock(pthread_mutex_t * mutex)
{
switch (mutex->__m_kind) {
case PTHREAD_MUTEX_ADAPTIVE_NP:
- __pthread_unlock(&mutex->__m_lock);
+ if (mutex->__m_lock.__status != 0)
+ __pthread_unlock(&mutex->__m_lock);
return 0;
case PTHREAD_MUTEX_RECURSIVE_NP:
if (mutex->__m_owner != thread_self())
Unfortunately this seems to break crisv32 support. (qemu-system-cris)
The ex1 test is failing (never ends).
You can either verify this directly with OpenADK or embedded-test.sh
from
embedded-test.org:
mksh embedded-test.sh --arch=crisv32 --debug --libc=uclibc-ng --test=libc
--libc-source=uclibc-ng/
uclibc-ng directory is latest git with your linuxthreads.old patches.
Any idea? On which arch you have tested?
best regards
Waldemar