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


##########
be/src/runtime/thread_context.cpp:
##########
@@ -25,6 +25,35 @@ namespace doris {
 class MemTracker;
 
 void AttachTask::init(const std::shared_ptr<ResourceContext>& rc) {
+    // Validate the ResourceContext chain before mutating any thread-local
+    // or signal state. If any link is null we throw immediately, so the
+    // caller's stack-unwind sees a clean state (no thread-local handle is
+    // acquired and no signal task id is set). Without these the previous
+    // code would silently propagate a null mem_tracker into
+    // ThreadMemTrackerMgr and crash much later inside the allocator.
+    if (UNLIKELY(rc == nullptr)) {

Review Comment:
   These new `throw Exception(Status::FatalError(...))` checks change 
`SCOPED_ATTACH_TASK(...)` from a local crash into an exception, but several 
existing attach sites run at plain async callback entry points that do not have 
a catch-and-convert boundary above them. For example, 
`SchemaScanner::get_next_block_async()` and `AsyncResultWriter::start_writer()` 
call `SCOPED_ATTACH_TASK(state)` inside lambdas submitted to `FragmentMgr`'s 
`ThreadPool`, and `ThreadPool::dispatch_thread()` just executes 
`task.runnable->run()` without catching `doris::Exception`. If one of these new 
checks fires, the exception escapes the worker thread and `std::terminate`s the 
whole BE instead of failing only that query. Could we either add the required 
exception boundary around every async attach entry or keep these diagnostics in 
a non-throwing form at those entry points?



-- 
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