apache / apache/brpc

crash at `bthread_setspecific` log fatal

Open
#2,198 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
17.6k
Forks
4.1k
Avg merge
2d 12h
Merged PRs (30d)
69

Description

**Describe the bug (描述bug)**

I use brpc in my application. it will crash. Other compilation methods are fine. But brpc compiles the same way
```
LDFLAGS="${ldflags}" \
"${CMAKE_CMD}" -G "${GENERATOR}" -DBUILD_SHARED_LIBS=1 -DWITH_GLOG=ON -DCMAKE_INSTALL_PREFIX="${TP_INSTALL_DIR}" \
-DCMAKE_LIBRARY_PATH="${TP_INSTALL_DIR}/lib64" -DCMAKE_INCLUDE_PATH="${TP_INSTALL_DIR}/include" \
-DBUILD_BRPC_TOOLS=OFF \
-DPROTOBUF_PROTOC_EXECUTABLE="${TP_INSTALL_DIR}/bin/protoc" ..
```

```
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1 0x00007f5d6b9bc859 in __GI_abort () at abort.c:79
#2 0x000056049cdc1a19 in ?? ()
#3 0x000056049cdb702d in google::LogMessage::Fail() ()
#4 0x000056049cdb9569 in google::LogMessage::SendToLog() ()
#5 0x000056049cdb6b96 in google::LogMessage::Flush() ()
#6 0x000056049cdb9bd9 in google::LogMessageFatal::~LogMessageFatal() ()
#7 0x000056049d575ef5 in bthread_setspecific ()
#8 0x0000560476c31604 in doris::pthread_attach_bthread () at /doris_master/doris/be/src/runtime/thread_context.h:211
#9 0x0000560476c2cd38 in doris::thread_context () at /doris_master/doris/be/src/runtime/thread_context.h:220
#10 0x0000560476c2cde0 in doris_free (p=0x7f5a8e852000) at /doris_master/doris/be/src/runtime/memory/jemalloc_hook.cpp:43
#11 0x000056049d53278b in butil::iobuf::release_tls_block_chain(butil::IOBuf::Block*) ()
#12 0x000056049d535ca1 in butil::IOPortal::pappend_from_file_descriptor(int, long, unsigned long) ()
#13 0x000056049d5f632f in brpc::InputMessenger::OnNewMessages(brpc::Socket*) ()
#14 0x000056049d71a00e in brpc::Socket::ProcessEvent(void*) ()
#15 0x000056049d5897ff in bthread::TaskGroup::task_runner(long) ()
#16 0x000056049d575091 in bthread_make_fcontext ()
```

**To Reproduce (复现方法)**

**Expected behavior (期望行为)**

**Versions (各种版本)**
OS:
Compiler:
brpc:
protobuf:

**Additional context/screenshots (更多上下文/截图)**

Contributor guide

Open the contributing guide

Research direction

Start with the bthread_setspecific stack frame and inspect doris::pthread_attach_bthread in src/runtime/thread_context.h and doris_free in src/runtime/memory/jemalloc_hook.cpp. Reproduce the crash with the shown shared-library CMake configuration, then document the cause and verify that the fatal log no longer occurs; the issue provides no named test or complete reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
backend, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.