Skip to content

Conversation

@bneradt
Copy link
Contributor

@bneradt bneradt commented Dec 31, 2025

The DbgCtl registry was experiencing use-after-free crashes during program shutdown, particularly visible in CI regression tests. The root cause was the undefined destruction order of static objects in C++.

Problem:

  • DbgCtl objects can be static or thread-local with lifetimes spanning program execution
  • When one compilation unit's DbgCtl destructs and triggers registry cleanup, other compilation units may still have DbgCtl objects with pointers into that registry
  • Thread exit order is also unpredictable, causing similar issues when thread-local DbgCtl objects destruct

This implements the "leaky singleton" pattern where the registry is:

  • Created on first use
  • Never destroyed (destructor is now = default)
  • Memory (~20KB) reclaimed by OS at process exit

Fixes: #12776

@bneradt bneradt added this to the 10.2.0 milestone Dec 31, 2025
@bneradt bneradt self-assigned this Dec 31, 2025
@bneradt bneradt force-pushed the fix_centos_dbg_ctl_destruction_crash branch 5 times, most recently from e61d46f to c2b38b0 Compare December 31, 2025 22:01
The DbgCtl registry was experiencing use-after-free crashes during program
shutdown, particularly visible in CI regression tests. The root cause
was the undefined destruction order of static objects in C++.

Problem:
- DbgCtl objects can be static or thread-local with lifetimes spanning program
  execution
- When one compilation unit's DbgCtl destructs and triggers registry cleanup,
  other compilation units may still have DbgCtl objects with pointers into
  that registry
- Thread exit order is also unpredictable, causing similar issues when
  thread-local DbgCtl objects destruct

This implements the "leaky singleton" pattern where the registry is:
- Created on first use
- Never destroyed (destructor is now = default)
- Memory (~20KB) reclaimed by OS at process exit

Fixes: apache#12776
@bneradt bneradt force-pushed the fix_centos_dbg_ctl_destruction_crash branch from c2b38b0 to 0399044 Compare December 31, 2025 22:34
@bneradt
Copy link
Contributor Author

bneradt commented Jan 2, 2026

[approve ci fedora]

@bneradt bneradt force-pushed the fix_centos_dbg_ctl_destruction_crash branch 8 times, most recently from 6e87b0c to 786bd8b Compare January 2, 2026 22:50
@bneradt
Copy link
Contributor Author

bneradt commented Jan 2, 2026

[approve ci fedora]

@bneradt bneradt force-pushed the fix_centos_dbg_ctl_destruction_crash branch 6 times, most recently from 2ab9d48 to ac1ccb5 Compare January 3, 2026 03:48
@bneradt bneradt force-pushed the fix_centos_dbg_ctl_destruction_crash branch from ac1ccb5 to 861f946 Compare January 3, 2026 04:03
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.

CI Crashes Due to DbgCtl Use-After-Free

1 participant