Signal callbacks: Wait for running callbacks on deregistration #16836
All Vouch review confidence checks passed
Residual risk 0.09 = Change Risk (0.33) × (1 − Review Confidence (0.73)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.33 · 77 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.61 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
Diff Size
diff_size
0.261
Real PR Conversation Timeline
3 items
roberth
edolstra
<!--
IMPORTANT
Nix is a non-trivial project, so for your contribution to be successful,
it really is important to follow the contributing guidelines:
https://github.com/NixOS/nix/blob/master/CONTRIBUTING.md
Even if you've contributed to open source before, take a moment to read it,
so you understand the process and the expectations.
PR stuck in review? We have two Nix team meetings per week online that are open for everyone in a jitsi conference:
-->
Motivation
Fixes crashes where a signal callback runs after it has been deregistered and the objects it refers to have been destroyed. We saw this in crash reports from Determinate Nix, in
nix-daemon(the interrupt callback inprocessConnection()) and innix build(theReceiveInterruptscallback).triggerSignalCallbacks()calls a copy of the callback after releasing the lock, and deregistration didn't wait for it to finish.Taken from https://github.com/DeterminateSystems/nix-src/pull/795.
Implementation
Add a mutex that is held while looking up and running a callback, and while deregistering one, so deregistration waits until no callback is running. Includes a unit test that fails without the fix.
<!-- Invasive change: Discuss alternative designs or approaches you considered. -->
<!-- Large change: Tell reviewers how to read the diff, e.g. which commits or files to look at first. -->
---
Add :+1: to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.