Skip to content

[geom] Fix stale thread-local navigators across manager lifetimes - #22937

Open
agheata wants to merge 1 commit into
root-project:masterfrom
agheata:geom/fix-navigator-lifetime
Open

[geom] Fix stale thread-local navigators across manager lifetimes#22937
agheata wants to merge 1 commit into
root-project:masterfrom
agheata:geom/fix-navigator-lifetime

Conversation

@agheata

@agheata agheata commented Jul 27, 2026

Copy link
Copy Markdown
Member

This Pull request:

Repeatedly executing a geometry macro that creates a TGeoManager, calls
CheckOverlaps(), and draws the geometry can crash when interacting with the
canvas.

The parallel overlap check creates navigators for its worker threads.
TGeoManager::GetCurrentNavigator() caches these pointers in thread-local
storage. Deleting the manager destroys the navigators, but the caches belonging
to persistent worker threads remain alive. When these workers are reused for a
new geometry, they can return a dangling navigator from the previous manager.

Changes or fixes:

  • Associate the thread-local navigator and thread ordinal with the current
    manager and an atomic geometry-state generation.
  • Invalidate cached state when navigator or thread state is destroyed or reset,
    including during manager teardown.
  • Update only the calling thread's cache when adding or selecting a navigator,
    preserving independent navigators created concurrently by different threads.
  • Synchronize shared navigator-map lookups and first-time thread registration.
  • Replace the manager-blind thread_local initialization flags in the parallel
    overlap checker with a check against the current manager.
  • Add gtest-geom-manager-lifetime, covering:
    • concurrent creation and selection of independent per-thread navigators;
    • repeated manager recreation after a parallel CheckOverlaps() call.

There are no public API, class-layout, dictionary, or I/O changes.

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

This PR fixes the issue reported in the forum: https://root-forum.cern.ch/t/crash-in-geometry-after-checkoverlaps/64954

Invalidate cached navigator and thread-ID state across geometry manager lifetimes while keeping navigator selection local to each worker thread. Synchronize shared navigator-map lookups and add regression coverage for concurrent navigator creation and manager recreation after parallel overlap checks.
@agheata agheata self-assigned this Jul 27, 2026
@agheata
agheata requested a review from bellenot as a code owner July 27, 2026 14:16
@github-actions

Copy link
Copy Markdown

Test Results

    23 files      23 suites   3d 14h 24m 10s ⏱️
 3 878 tests  3 877 ✅ 0 💤 1 ❌
78 979 runs  78 978 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit d6d85f1.

@dpiparo
dpiparo self-requested a review July 28, 2026 04:48
@dpiparo

dpiparo commented Jul 28, 2026

Copy link
Copy Markdown
Member

Thanks. Please merge at your earliest convenience and backport to 6.40.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants