Occasional crashes with "The futex facility returned an unexpected error code."

2,521 views
Skip to first unread message

Jonas

unread,
Oct 13, 2017, 3:35:01 AM10/13/17
to libxbee
Hey,

its me again, I noticed another problem, I'm not sure if the cause lies within libxbee, but I spent a couple of hours trying to solve it and I'm stuck now, so I thought I might as well ask.
When using connections with the noWaitForAck flag set (for example a broadcast connection, but also on individual connections) it occasionally happens that my application crashes with the above error message.
When I try to transmit larger/more packages the crasher occur sooner. (But still seemingly random)
According to my debugger the last function call is in line 114 of tx.c:
xsys_sem_post(&buf->sem);
after that a couple of futex internal calls happen.

The full call stack is:
#0 0x7ffff6b42418    __GI_raise(sig=sig@entry=6) (../sysdeps/unix/sysv/linux/raise.c:54)
#1 0x7ffff6b4401a    __GI_abort() (abort.c:89)
#2 0x7ffff6b8472a    __libc_message(do_abort=do_abort@entry=1, fmt=fmt@entry=0x7ffff6c9baa9 "%s") (../sysdeps/posix/libc_fatal.c:175)
#3 0x7ffff6b8474e    __GI___libc_fatal(message=message@entry=0x7ffff7789b40 "The futex facility returned an unexpected error code.") (../sysdeps/posix/libc_fatal.c:185)
#4 0x7ffff7786c8e    futex_fatal_error() (../sysdeps/nptl/futex-internal.h:200)
#5 ??    futex_wake (private=<optimized out>, processes_to_wake=1, futex_word=<optimized out>) (../sysdeps/unix/sysv/linux/futex-internal.h:247)
#6 ??    __new_sem_post (sem=<optimized out>) (sem_post.c:57)
#7 0x7ffff79a0ceb    xbee_tx(xbee=0x631180, restart=0x7ffff5901e7c, arg=0x6317f0) (tx.c:114)
#8 0x7ffff79a4fab    threadFunc(thread=0x62f6d0) (thread.c:74)
#9 0x7ffff777e6fa    start_thread(arg=0x7ffff5902700) (pthread_create.c:333)
#10 0x7ffff6c13b5d    clone() (../sysdeps/unix/sysv/linux/x86_64/clone.S:109)

I don't really know how to proceed here, since it seems to be some kind of multithread issue. I would totally be ok if the package would just be lost, I just need it not to cause my program to crash.
Does anybody have an idea?

Best regards,
Jonas

Jonas

unread,
Oct 25, 2017, 2:29:51 AM10/25/17
to libxbee
For anybody experiencing the same problem:
I solved it by adding a check of the FrameID (buf->data[1]) and only calling
xsys_sem_post(&buf->sem); if the FrameID is != 0.
Probably not the cleanest solution, but it works for me...

Attie Grande

unread,
Nov 24, 2017, 10:10:13 AM11/24/17
to Jonas, libxbee
Hello Jonas,

Please could you apply and test the attached patch?
If things work out, then I will commit this and push it.

Thanks very much,
Attie

--
You received this message because you are subscribed to the Google Groups "libxbee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to libxbee+unsubscribe@googlegroups.com.
To post to this group, send email to lib...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/libxbee/7d167f00-dbd9-477a-809c-3ff417c94454%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

waitForAck_post_fix.patch
Reply all
Reply to author
Forward
Message has been deleted
0 new messages