Skip to content

branch-4.1: [Chore](check) add some Sanity-check for avoid npe #62691#62807

Open
github-actions[bot] wants to merge 1 commit intobranch-4.1from
auto-pick-62691-branch-4.1
Open

branch-4.1: [Chore](check) add some Sanity-check for avoid npe #62691#62807
github-actions[bot] wants to merge 1 commit intobranch-4.1from
auto-pick-62691-branch-4.1

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Cherry-picked from #62691

@github-actions github-actions Bot requested a review from yiguolei as a code owner April 24, 2026 08:41
@Thearas
Copy link
Copy Markdown
Contributor

Thearas commented Apr 24, 2026

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@dataroaring dataroaring reopened this Apr 24, 2026
@Thearas
Copy link
Copy Markdown
Contributor

Thearas commented Apr 24, 2026

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 13.76% (15/109) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 54.40% (20010/36783)
Line Coverage 35.35% (180995/511952)
Region Coverage 29.56% (132586/448468)
Branch Coverage 31.15% (59144/189867)

@yiguolei yiguolei force-pushed the auto-pick-62691-branch-4.1 branch from 7061fea to f8bedfc Compare April 24, 2026 20:02
@yiguolei
Copy link
Copy Markdown
Contributor

run buildall

This pull request adds comprehensive null pointer checks and improved
error reporting to critical memory management and pipeline execution
paths. The main goal is to catch and clearly report misuses or
unexpected nulls in resource and memory tracker objects, especially in
RELEASE builds where previous checks (like DCHECK) were no-ops. This
should make debugging memory management and pipeline execution issues
much easier by providing explicit error messages and context, rather
than opaque crashes or silent failures.

The most important changes are:

**Memory Tracker Safety and Error Reporting:**

* Added explicit null checks and detailed exception throwing in
`ThreadMemTrackerMgr` methods, including `attach_limiter_tracker`,
`detach_limiter_tracker`, and `limiter_mem_tracker`, to prevent
propagation of null memory tracker pointers and provide clear
diagnostics when misuse occurs.
[[1]](diffhunk://#diff-d22d036bc75761be008a06388ac64878a0150314aad313ba63cb1e70d6b98f67R22-R39)
[[2]](diffhunk://#diff-d22d036bc75761be008a06388ac64878a0150314aad313ba63cb1e70d6b98f67R68-R86)
[[3]](diffhunk://#diff-65c8664db7728c5cc60ea7ae8434dc47014b2531e03072333a5989554b747029R105-R113)
* Improved header includes to ensure `common/exception.h` is available
where exceptions are thrown.

**Resource Context Initialization and Validation:**

* Added step-by-step null checks in `AttachTask` and
`SwitchResourceContext` constructors to pinpoint exactly which part of
the resource context chain is null, throwing a `FatalError` with clear
context if any are missing.
[[1]](diffhunk://#diff-2b2f9638f5ba33910b1e2325b34ad4f99d4b9da393a9458858471cd84bf4e9e6R47-R61)
[[2]](diffhunk://#diff-2b2f9638f5ba33910b1e2325b34ad4f99d4b9da393a9458858471cd84bf4e9e6R82-R96)
* Enhanced `ThreadContext::attach_task` to check for null
`ResourceContext`, `MemoryContext`, and `mem_tracker` before attaching,
with detailed error messages to aid debugging of half-initialized or
misused contexts.

**Pipeline Execution Robustness:**

* Added sanity checks for null pointers in the `PipelineTask::execute`
method before dereferencing critical objects, throwing an exception with
query ID and pointer values for easier triage if any are unexpectedly
null.
[[1]](diffhunk://#diff-b1379f2a0e6db93d3aaeec091b10d8a13e9461322f30af2c3f4a54df5bee702fR511-R520)
[[2]](diffhunk://#diff-b1379f2a0e6db93d3aaeec091b10d8a13e9461322f30af2c3f4a54df5bee702fR31)

These changes collectively increase the safety and debuggability of
memory and resource management in the codebase, reducing the risk of
silent failures and making it easier to identify the root cause of any
issues.
@morningman
Copy link
Copy Markdown
Contributor

run buildall

@morningman morningman force-pushed the auto-pick-62691-branch-4.1 branch from f8bedfc to dbad61b Compare April 24, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants