Skip to content

Cyber: prevent queued timer callback use-after-free - #15814

Open
timothyanderson096-ocdealcheck wants to merge 1 commit into
ApolloAuto:masterfrom
timothyanderson096-ocdealcheck:fix-15810-timing-wheel-callback-lifetime
Open

Cyber: prevent queued timer callback use-after-free#15814
timothyanderson096-ocdealcheck wants to merge 1 commit into
ApolloAuto:masterfrom
timothyanderson096-ocdealcheck:fix-15810-timing-wheel-callback-lifetime

Conversation

@timothyanderson096-ocdealcheck

Copy link
Copy Markdown

Summary

  • replace the queued raw callback pointer with a weak TimerTask reference
  • discard queued work when Timer::Stop() has already destroyed the task
  • preserve the canonical callback object across periodic firings
  • add regressions for stop-before-dequeue lifetime and mutable callback state

Rationale

Capturing a strong task reference would keep a stopped timer alive, while copying the callback would change stateful periodic-callback semantics. Locking a weak task reference at execution time avoids the reported use-after-free without either behaviour change.

Testing

  • added TimerConcurrencyTest.stop_before_queued_callback_runs
  • added TimerTest.periodic_callback_preserves_state
  • standalone ASan reproducer: the original raw-pointer path reports heap-use-after-free; the weak-reference path completes without invoking the stopped callback
  • git diff --check

The Apollo Bazel target could not be run locally because the Apollo development container/toolchain was unavailable. Repository CI will provide the project-level build and test result.

Fixes #15810

Queue a weak TimerTask reference so callbacks discarded by Timer::Stop() cannot outlive their owning task. Add queued-callback and mutable callback state regressions.

Fixes ApolloAuto#15810
@CLAassistant

CLAassistant commented Aug 30, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@ZeusJupiter

ZeusJupiter commented Aug 30, 2026 via email

Copy link
Copy Markdown
Contributor

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.

TimingWheel::Tick() use-after-free crash when Timer::Stop() called concurrently

3 participants