github-actions[bot] commented on code in PR #70633:
URL: https://github.com/apache/doris/pull/70633#discussion_r4611087233


##########
be/src/service/http/action/be_thread_stack_action.cpp:
##########
@@ -149,7 +149,7 @@ void capture_signal_context_unwind(const ucontext_t* 
context, SignalContextCaptu
         return;
     }
 
-#if defined(USE_UNWIND) && USE_UNWIND && defined(__x86_64__)
+#if defined(USE_UNWIND) && USE_UNWIND

Review Comment:
   [P1] Fix mini-debug allocator state before enabling ARM64
   
   On an ARM64 frame without usable DWARF, the newly enabled `unw_step` falls 
back through `get_frame_state` → `get_proc_name` → `extract_minidebuginfo`. For 
an ELF image containing `.gnu_debugdata`, the pinned [libunwind 1.8.3 
decoder](https://github.com/libunwind/libunwind/blob/v1.8.3/src/elfxx.c#L530) 
passes an uninitialized automatic `xz_allocator_data` to liblzma. `xz_alloc` 
uses its indeterminate `n_allocs` to index a 16-entry array (rejecting only 
equality with 16), and cleanup uses the same count to unmap records. This can 
write beyond the handler's stack object or unmap unrelated memory during a 
stack request. The existing Doris PHDR patch does not initialize this state, 
and process-wide unwinder initialization cannot initialize an automatic object. 
Require the dependency fix, or disable this fallback in the consumed library, 
before enabling ARM64 signal capture.



##########
be/src/service/http/action/be_thread_stack_action.cpp:
##########
@@ -243,7 +244,7 @@ void install_signal_handler() {
         LOG(FATAL) << "SIGRTMIN+" << STACK_TRACE_SIGNAL_OFFSET << " exceeds 
SIGRTMAX";
     }
 
-#if defined(USE_UNWIND) && USE_UNWIND && defined(__x86_64__)
+#if defined(USE_UNWIND) && USE_UNWIND

Review Comment:
   [P1] Reject unavailable PHDR caches before installing the handler
   
   For a Linux ARM64 `BUILD_TYPE=TSAN` build, CMake still enables `USE_UNWIND`, 
while `THREAD_SANITIZER` disables the PHDR cache (`phdr_cache.cpp`: 
`updatePHDRCache()` is a no-op and `hasPHDRCache()` returns false). Removing 
the architecture guard here therefore makes the first `/api/stack_trace` 
request reach `LOG(FATAL)` and terminate the BE. `handle()` calls 
`install_signal_handler` through `call_once` before parameter validation and 
before `prepare_signal_capture` can return its normal unavailable-cache error. 
Previously ARM64 skipped this fatal prerequisite and returned unsupported. 
Check for unavailable-cache configurations and return an HTTP error before 
installation, or supply a safe cache implementation first; changing only the 
later prepare check cannot prevent this abort.



##########
be/src/service/http/action/be_thread_stack_action.cpp:
##########
@@ -196,11 +196,12 @@ void capture_signal_context_unwind(const ucontext_t* 
context, SignalContextCaptu
 #endif
 }
 
-// SAFETY: this handler only runs libunwind against the kernel-provided signal 
context and writes
-// raw PCs into a preallocated process-wide slot. It never symbolicates, logs, 
allocates strings, or
-// opens /proc. The PHDR cache scope is deliberately limited to this handler: 
a target thread may be
-// interrupted while already holding glibc's loader lock, but normal 
sanitizer/JVM/exception paths
-// must still see the live loader list through the original dl_iterate_phdr 
implementation.
+// SAFETY: Doris only writes raw PCs from the kernel-provided signal context 
into a preallocated
+// process-wide slot; it does not render symbols or log here. GNU libunwind's 
AArch64 fallback for
+// missing DWARF may still query procedure names, open /proc maps and ELF 
files, and decode
+// mini-debug data with its mmap-backed allocator. The PHDR cache scope is 
limited to this handler:

Review Comment:
   [P1] Remove allocator-backed debug-frame decoding from the handler
   
   The newly enabled ARM64 path can also allocate through ordinary zlib, 
independently of the mmap-backed mini-debug allocator described here. GNU 
libunwind 1.8.3 enables `CONFIG_DEBUG_FRAME` by default on AArch64; Doris's 
configure command leaves it and zlib support enabled. On a cold lookup of a 
compressed `.debug_frame` (including separate debuginfo), [`dwarf_callback` → 
`load_debug_frame`](https://github.com/libunwind/libunwind/blob/v1.8.3/src/dwarf/Gfind_proc_info-lsb.c#L153)
 calls `uncompress`, even when an EH table was found. [zlib's 
initializer](https://github.com/madler/zlib/blob/v1.3.1/inflate.c#L188) 
installs ordinary malloc/free callbacks. If the signal interrupts a worker 
holding a jemalloc arena/bin lock and that allocation needs the same lock, the 
target deadlocks inside the handler; the HTTP timeout cannot release it. 
Neither the PHDR snapshot nor `mode=disabled` prevents this. Keep this route 
disabled until the consumed dependency excludes these paths or provides s
 ignal-safe allocation throughout them.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to