Skip to content

Deadlock can be happen when b->waiter_lock is locked again in erase_from_butex_and_wakeup() #3253

@metalslug2023

Description

@metalslug2023

Describe the bug
#0 0x00007fbd0a804e29 in syscall () from /lib64/libc.so.6
#1 0x0000000000d5d3c3 in futex_wait_private (timeout=0x0, expected=257, addr1=0x7fbcc5d21018) at ./brpc/src/bthread/sys_futex.h:40
#2 bthread::internal::FastPthreadMutex::lock_contended (this=0x7fbcc5d21018) at ./brpc/src/bthread/mutex.cpp:685
#3 0x0000000000f14af4 in lock_guard (__m=..., this=) at /usr/include/c++/7/bits/std_mutex.h:162
#4 erase_from_butex (state=bthread::WAITER_STATE_TIMEDOUT, wakeup=true, bw=0x7fbceeffebb0) at ./brpc/src/bthread/butex.cpp:504
#5 erase_from_butex_and_wakeup (arg=0x7fbceeffebb0) at ./brpc/src/bthread/butex.cpp:487
#6 bthread::wait_for_butex (arg=0x7fbceeffebb0) at ./brpc/src/bthread/butex.cpp:558
#7 0x0000000000d6cf2e in bthread::TaskGroup::sched_to (pg=pg@entry=0x7fbc98deaaa0, next_meta=next_meta@entry=0x7fbcd40b4f90) at ./brpc/src/bthread/task_group.cpp:645
#8 0x0000000000d70573 in sched_to (next_tid=, pg=0x7fbc98deaaa0) at ./brpc/src/bthread/task_group_inl.h:78
#9 bthread::TaskGroup::run_main_task (this=this@entry=0x7fbcc5c83000) at ./brpc/src/bthread/task_group.cpp:162
#10 0x0000000000d612d6 in bthread::TaskControl::worker_thread (arg=) at ./brpc/src/bthread/task_control.cpp:99

To Reproduce
internal::FastPthreadMutex mux;
BAIDU_SCOPED_LOCK(mux);
BAIDU_SCOPED_LOCK(mux);

Expected behavior
No deadlock

Versions
OS: CentOS7
Compiler: GCC7
brpc: 1.8.0
protobuf: 3.1x

Additional context/screenshots

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions