Skip to content

链接jemalloc后可能会有死锁的问题 #859

@niukuo

Description

@niukuo

Describe the bug (描述bug)
jemalloc在申请内存时会有lock/unlock操作,brpc劫持了pthread_mutex_unlock函数后在submit_contention里面又有内存操作,导致出现死锁。

To Reproduce (复现方法)
在内存操作时有小概率出现。

Expected behavior (期望行为)

Versions (各种版本)
OS: centos 5.7
Compiler: CC=/usr/local/gcc-4.9.2/bin/gcc CXXFLAGS='-gdwarf-2'
brpc: 3becc72
protobuf:2.4.1

Additional context/screenshots (更多上下文/截图)
Thread 10 (Thread 0x7fe2009ff700 (LWP 17081)):
#0 0x00007fe28a98d51d in __lll_lock_wait () from /lib64/libpthread.so.0
#1 0x00007fe28a988e51 in _L_lock_1022 () from /lib64/libpthread.so.0
#2 0x00007fe28a988df2 in pthread_mutex_lock () from /lib64/libpthread.so.0
#3 0x0000000000ac982b in pthread_mutex_lock ()
#4 0x000000000050d860 in je_arena_choose_hard ()
#5 0x0000000000544028 in je_tcache_get_hard ()
#6 0x000000000051165b in malloc ()
#7 0x00000000011e97ec in operator new(unsigned long, std::nothrow_t const&) ()
#8 0x0000000000aca071 in bthread::submit_contention(bthread_contention_site_t const&, long) ()
#9 0x0000000000ac9bb7 in pthread_mutex_unlock ()
#10 0x0000000000522750 in je_base_alloc ()
#11 0x0000000000516f4f in je_arena_new ()
#12 0x000000000050d7ab in arena_init_locked ()
#13 0x000000000050d94d in je_arena_choose_hard ()
#14 0x0000000000544028 in je_tcache_get_hard ()
#15 0x000000000051165b in malloc ()
#16 0x00000000011f4cd8 in operator new(unsigned long) ()
#17 0x0000000000693e5e in std::function ()>::function, std::__future_base::_Result_base::_Deleter>, rocksdb::Status>, void>(std::__future_base::_Task_setter, std::__future_base::_Result_base::_Deleter>, rocksdb::Status>) ()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugthe code does not work as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions