Using the slack-typing-relay
demo program, the program typically deadlocks within a couple hours of launching and needs to be restarted.
The program is actually single-threaded in this case, and the deadlock is due to an attempt to recursively lock the same mutex again.
Backtrace while deadlocked:
Thread 1 (Thread 0x7f851a024740 (LWP 77940) "slack-typing-re"):
#0 futex_wait (private=0, expected=2, futex_word=0x5653079fb2f8) at ../sysdeps/nptl/futex-internal.h:146
__ret = -512
err = <optimized out>
err = <optimized out>
__ret = <optimized out>
resultvar = <optimized out>
__arg4 = <optimized out>
__arg3 = <optimized out>
__arg2 = <optimized out>
__arg1 = <optimized out>
_a4 = <optimized out>
_a3 = <optimized out>
_a2 = <optimized out>
_a1 = <optimized out>
#1 __GI___lll_lock_wait (futex=futex@entry=0x5653079fb2f8, private=0) at ./nptl/lowlevellock.c:49
No locals.
#2 0x00007f851a1743c2 in lll_mutex_lock_optimized (mutex=0x5653079fb2f8) at ./nptl/pthread_mutex_lock.c:48
__futex = 0x5653079fb2f8
private = <optimized out>
private = <optimized out>
__futex = <optimized out>
#3 ___pthread_mutex_lock (mutex=mutex@entry=0x5653079fb2f8) at ./nptl/pthread_mutex_lock.c:93
type = <optimized out>
__PRETTY_FUNCTION__ = "___pthread_mutex_lock"
id = <optimized out>
#4 0x00007f851a2ccc2d in slack_send (slack=0x5653079fb2a0, msgid=12, msg=<optimized out>, len=<optimized out>, expect_response=<optimized out>) at slack-client.c:976
reply = <optimized out>
c = 0 '\000'
pres = <optimized out>
res = <optimized out>
pfds = {{fd = 3, events = 1, revents = 1}, {fd = 5, events = 1, revents = 0}}
started = 1721153332
numfds = 2
__func__ = "slack_send"
#5 0x00007f851a2ce50c in send_and_wait (msg=0x565307b2ce80 "{\"id\": 12, \"type\": \"message\", \"channel\": \"REDACTED\", \"text\": \"<!here> Looks like <@REDACTED> just started typing in channel <REDACTED\"}", msgid=12, slack=0x5653079fb2a0) at slack-client.c:685
#6 slack_channel_post_message (slack=slack@entry=0x5653079fb2a0, channel=<optimized out>, thread_ts=thread_ts@entry=0x0, text=text@entry=0x7fffa62c8160 "<!here> Looks like <@REDACTED> just started typing in channel <REDACTED") at slack-client.c:709
#7 0x0000565306055b0f in user_typing (event=<optimized out>, channel=0x565307b2e040 "REDACTED", thread_ts=<optimized out>, id=26955, user=0x565307b2cdc0 "REDACTED") at slack-typing-relay.c:68
#8 0x00007f851a2cfcbc in slack_parse_message (cb=cb@entry=0x565306058100 <slack_callbacks>, userdata=userdata@entry=0x5653079fb2a0, buf=<optimized out>, len=len@entry=78) at slack-rtm.c:377
#9 0x00007f851a2cc93c in slack_read (slack=slack@entry=0x5653079fb2a0, cb=0x565306058100 <slack_callbacks>) at slack-client.c:648
#10 0x00007f851a2ccbed in slack_send (slack=0x5653079fb2a0, msgid=11, msg=<optimized out>, len=<optimized out>, expect_response=<optimized out>) at slack-client.c:1002
#11 0x00007f851a2ce50c in send_and_wait (msg=0x565307b3f320 "{\"id\": 11, \"type\": \"message\", \"channel\": \"REDACTED\", \"text\": \"<!here> Looks like <@REDACTED> just started typing in channel <REDACTED\"}", msgid=11, slack=0x5653079fb2a0) at slack-client.c:685
#12 slack_channel_post_message (slack=slack@entry=0x5653079fb2a0, channel=<optimized out>, thread_ts=thread_ts@entry=0x0, text=text@entry=0x7fffa62c8530 "<!here> Looks like <@REDACTED> just started typing in channel <REDACTED") at slack-client.c:709
#13 0x0000565306055b0f in user_typing (event=<optimized out>, channel=0x565307b3c1b0 "REDACTED", thread_ts=<optimized out>, id=26954, user=0x565307b2e2e0 "REDACTED") at slack-typing-relay.c:68
#14 0x00007f851a2cfcbc in slack_parse_message (cb=cb@entry=0x565306058100 <slack_callbacks>, userdata=userdata@entry=0x5653079fb2a0, buf=<optimized out>, len=len@entry=78) at slack-rtm.c:377
#15 0x00007f851a2cc93c in slack_read (slack=slack@entry=0x5653079fb2a0, cb=0x565306058100 <slack_callbacks>) at slack-client.c:648
#16 0x00007f851a2ce997 in slack_event_loop (slack=slack@entry=0x5653079fb2a0, cb=cb@entry=0x565306058100 <slack_callbacks>) at slack-client.c:856
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
futex_wait (private=0, expected=2, futex_word=0x5608d9cf32f8) at ../sysdeps/nptl/futex-internal.h:146
Thread 1 (Thread 0x7f831f3ef740 (LWP 17303) "slack-typing-re"):
#0 futex_wait (private=0, expected=2, futex_word=0x5608d9cf32f8) at ../sysdeps/nptl/futex-internal.h:146
__ret = -512
err = <optimized out>
err = <optimized out>
__ret = <optimized out>
resultvar = <optimized out>
__arg4 = <optimized out>
__arg3 = <optimized out>
__arg2 = <optimized out>
__arg1 = <optimized out>
_a4 = <optimized out>
_a3 = <optimized out>
_a2 = <optimized out>
_a1 = <optimized out>
#1 __GI___lll_lock_wait (futex=futex@entry=0x5608d9cf32f8, private=0) at ./nptl/lowlevellock.c:49
No locals.
#2 0x00007f831f5403c2 in lll_mutex_lock_optimized (mutex=0x5608d9cf32f8) at ./nptl/pthread_mutex_lock.c:48
__futex = 0x5608d9cf32f8
private = <optimized out>
private = <optimized out>
__futex = <optimized out>
#3 ___pthread_mutex_lock (mutex=mutex@entry=0x5608d9cf32f8) at ./nptl/pthread_mutex_lock.c:93
type = <optimized out>
__PRETTY_FUNCTION__ = "___pthread_mutex_lock"
id = <optimized out>
#4 0x00007f831f698c2d in slack_send (slack=0x5608d9cf32a0, msgid=6, msg=<optimized out>, len=<optimized out>, expect_response=<optimized out>) at slack-client.c:976
reply = <optimized out>
c = 0 '\000'
pres = <optimized out>
res = <optimized out>
pfds = {{fd = 3, events = 1, revents = 1}, {fd = 5, events = 1, revents = 1}}
started = 1719336656
numfds = 2
__func__ = "slack_send"
You must be