Skip to content

DPL: make ServiceRegistryRef's constructor explicit - #16205

Open
ktf wants to merge 1 commit into
AliceO2Group:devfrom
ktf:pr16205
Open

ktf wants to merge 1 commit into
AliceO2Group:devfrom
ktf:pr16205

Conversation

@ktf

@ktf ktf commented Nov 26, 2026

Copy link
Copy Markdown
Member

A ServiceRegistryRef built from a bare ServiceRegistry takes the device salt from
a default argument, so anywhere a function wants a ref and is handed a registry,
one is conjured silently -- including on a worker, where it claims to be the main
thread. Requiring it to be spelled out means the salt has to be chosen on
purpose.

Doing so found two places where it was the wrong one. doRun is handed a ref
carrying the salt of the stream it is running for, but built its DanglingContext
and EndOfStreamContext from *context.registry, which silently produced a
device-level ref, so everything those callbacks reach went looking in the wrong
place. They now use the ref they were given.

That also defeated a check which exists precisely to stop this: flushMetrics
refuses to run unless isMainThread(), and with a device-level ref manufactured on
a pool thread it happily agreed. Rather than the intended fatal, it went on to
race the driver and die in DPLMonitoringBackend::send with a bad_variant_access.

Every other call site is device level and now says so.

A ServiceRegistryRef built from a bare ServiceRegistry takes the device salt from
a default argument, so anywhere a function wants a ref and is handed a registry,
one is conjured silently -- including on a worker, where it claims to be the main
thread. Requiring it to be spelled out means the salt has to be chosen on
purpose.

Doing so found two places where it was the wrong one. doRun is handed a ref
carrying the salt of the stream it is running for, but built its DanglingContext
and EndOfStreamContext from *context.registry, which silently produced a
device-level ref, so everything those callbacks reach went looking in the wrong
place. They now use the ref they were given.

That also defeated a check which exists precisely to stop this: flushMetrics
refuses to run unless isMainThread(), and with a device-level ref manufactured on
a pool thread it happily agreed. Rather than the intended fatal, it went on to
race the driver and die in DPLMonitoringBackend::send with a bad_variant_access.

Every other call site is device level and now says so.
@ktf
ktf requested a review from a team as a code owner November 26, 2026 12:17

This branch has not been deployed

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant