The futex facility returned an unexpected error code?
Asked Answered
M

3

11

Two threads in same process using rwlock object stored in shared memory encounter crash during pthreads stress test. I spent a while trying to find memory corruption or deadlock but nothing so far. is this just an less than optimal way of informing me I have created a deadlock? Any pointers on tools/methods for debugging this?

Thread 5 "tms_test" received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffff28a7700 (LWP 3777)]
0x00007ffff761e428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54  ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff761e428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007ffff762002a in __GI_abort () at abort.c:89
#2  0x00007ffff76607ea in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7ffff77776cc "%s") at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007ffff766080e in __GI___libc_fatal (message=message@entry=0x7ffff79c4ae0 "The futex facility returned an unexpected error code.") at ../sysdeps/posix/libc_fatal.c:185
#4  0x00007ffff79be7e5 in futex_fatal_error () at ../sysdeps/nptl/futex-internal.h:200
#5  futex_wait (private=, expected=, futex_word=0x7ffff7f670d9) at ../sysdeps/unix/sysv/linux/futex-internal.h:77
#6  futex_wait_simple (private=, expected=, futex_word=0x7ffff7f670d9) at ../sysdeps/nptl/futex-internal.h:135
#7  __pthread_rwlock_wrlock_slow (rwlock=0x7ffff7f670cd) at pthread_rwlock_wrlock.c:67
#8  0x00000000004046e3 in _memstat (offset=0x7fffdc0b11a5, func=0x0, lineno=0, size=134, flag=1 '\001') at tms_mem.c:107
#9  0x000000000040703b in TmsMemReallocExec (in=0x7fffdc0abb81, size=211, func=0x43f858  "_malloc_thread", lineno=478) at tms_mem.c:390
#10 0x000000000042a008 in _malloc_thread (arg=0x644c11) at tms_test.c:478
#11 0x000000000041a1d6 in _threadStarter (arg=0x644c51) at tms_mem.c:2384
#12 0x00007ffff79b96ba in start_thread (arg=0x7ffff28a7700) at pthread_create.c:333
#13 0x00007ffff76ef82d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
(gdb) 
Migraine answered 27/3, 2017 at 2:9 Comment(0)
H
10

It's pretty hard to debug something what is not documented well. I was trying to find any helpful information about "The futex facility returned an unexpected error code" but it seems that it isn't specified in futex documentation. In my case this message was generated by sem_wait(sem), where sem wasn't valid sem_t pointer. I was accidentally overwriting it (the memory pointed by sem) with some random integers after initializing sem with sem_init(sem,1,1). Try checking if you are passing valid pointer to locking function.

Hubbell answered 17/5, 2017 at 11:4 Comment(1)
This was kind of the situation for me also. I have a centralized data structure with interfaces to exchange data via shared memory. I recently changed the data structure size, but with one program forgot to recompile it in. This resulted in quite scary moments seeing the program "suddenly" crash. But after recompiling with the updated structure I was fine again.Angary
C
2

I was getting this error when i declared sem_t mutex as local variable.

Czarist answered 8/3, 2020 at 13:39 Comment(0)
L
0

Accessing a global inside an async did this for me.

Lightfooted answered 2/1 at 15:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.