← Back to Pull requests

[core] Make TStorage::fgMaxBlockSize updates atomic #24447

Open
unknown opened this pull request with 227 lines diff across 2 files
View on GitHub
unknown unknown commented on Dec 01, 2026 11:55 UTC
Author

This Pull request:

Changes or fixes:

In multithreaded programs linked with libNew, TStorage::EnterStat and the #ifndef MEM_STAT fallback in NewDelete.cxx updated the static TStorage::fgMaxBlockSize via an unsynchronized read-modify-write (SetMaxBlockSize(max(GetMaxBlockSize(), size))). A concurrent smaller allocation could overwrite a larger maximum recorded by another thread, causing CheckFreeSize in operator delete to abort with unreasonable size in addition to being a data race.

This PR makes TStorage::fgMaxBlockSize a std::atomic<size_t>, introduces TStorage::UpdateMaxBlockSize(size_t) using a monotonic compare_exchange_weak loop so the recorded maximum can never decrease under concurrent allocations (and smaller allocations avoid unnecessary writes), switches both EnterStat call sites to it, and adds a concurrent unit test in core/base/test/TStorageTests.cxx.

Local testing note: verified via a standalone harness compiling core/base/src/TStorage.cxx and running the concurrent test logic (reproducing lost updates under -O2 and data races under -fsanitize=thread before the change, and confirming 0 lost updates and 0 ThreadSanitizer warnings after), syntax-checked NewDelete.cxx and TStorageTests.cxx with -Wall -Wextra, and verified formatting against .clang-format with git-clang-format. (A full ROOT CMake build was not run locally.)

AI-assisted coding disclosure:

An AI coding assistant (Antigravity) was used to assist with investigating #24438, drafting the patch and unit test, and preparing the commit message and PR description. I have reviewed, understood, and verified all changes locally and take full responsibility for them.

Checklist:

  • tested changes locally

  • updated the docs (if necessary)
  • This PR fixes #24438

    Diff: 227 lines (+170 / -57) across 2 files Reviewer: pcanal Review duration: 3328m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.37) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 227 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.325
    Real PR Conversation Timeline
    1 comments
    "Review active on #24447"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.9% (MEDIUM) · Higher = larger blast radius
    36.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.7% · Safe to merge
    19.7%