Skip to content

Tracer caught signal 11 if asan is enabled #3302

@BusyJay

Description

@BusyJay

Describe the bug
Tracer caught signal 11: addr=0x7f57067db000 pc=0x7f572d0c3010 sp=0x7f5721313d10
==140089==LeakSanitizer has encountered a fatal error.
==140089==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
==140089==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)

To Reproduce
None yet.

Expected behavior
It works.

Versions
OS:
Compiler:
brpc:
protobuf:

Additional context/screenshots

Analysis from AI:

新版 brpc 在 BUTIL_USE_ASAN 路径下,对每段 bthread 协程栈(small/normal/large,1MB ~ 8MB)调用 __asan_poison_memory_region,把整段栈在 ASan shadow memory 里标为 unaddressable:

BUTIL_FORCE_INLINE void ASanPoisonMemoryRegion(const StackStorage& storage) {
    if (NULL == storage.bottom) return;
    BUTIL_ASAN_POISON_MEMORY_REGION(
        (char*)storage.bottom - storage.stacksize, storage.stacksize);
}

调用点:

  • stack_inl.h:136 — Wrapper 构造时 poison
  • stack_inl.h:158return_stack 把协程栈归还 ObjectPool 时 poison

每个 worker pthread 持有数十段协程栈,进程内累积 GB 级 poisoned mmap 区域。

进程退出时触发链路:

__cxa_finalize
  → __lsan::DoLeakCheck()
    → StopTheWorld
      → ListThreads (getdents /proc/<pid>/task)
      → GetThreadRangesLocked (读 AsanThread 的 stack/TLS 范围)
      → ScanRangeForPointers (扫描每个线程栈作为 root set)
        → 触碰被 brpc poison 的协程栈区域
          → ASan shadow check 内部异常
            → SIGSEGV
              → mysqld abnormal exit
                → shutdown_report fail

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