fix(time): keep alarm(0) disarmed when no timer exists - #2308
Merged
fslongjin merged 1 commit intoSep 21, 2026
Merged
Conversation
The empty alarm slot path created a timer before checking whether seconds was zero. A first alarm(0), or another cancellation after disarming, thus queued an immediately expiring timer and delivered an unexpected SIGALRM. Git upload-pack calls alarm(0) during local object transfer, so the sender could terminate and leave clone/fetch reporting early EOF or bad pack headers. Return zero from the existing locked empty-slot branch for a zero duration. Leave nonzero scheduling and the existing timer cancellation/replacement paths unchanged. The generic timer queue and Git behavior need no changes. Add a whitelisted dunitest suite for first cancellation, repeated cancellation, cancellation after disarming, and nonzero alarm delivery. Isolate signal state in child processes and use a monotonic parent-side watchdog independent of alarm(). Validation: - Linux: all four new cases pass. - Before the fix in DragonOS: all three zero-cancellation cases terminate with SIGALRM; the nonzero delivery case passes. - After the fix in DragonOS: all four pass, including three additional runs. - Adjacent poll timeout cases: 4/4; POSIX relative timer cases: 9/9. - Original alarm(0) reproducer exits normally after the fix. - Git 2.43.0 file:// clone and incremental pull pass with matching HEADs and successful fsck; the previously failing local-path pull also passes. - Git commit/merge/stash/push/gc/archive/bundle and HTTPS shallow clone pass. - make kernel, FMT_CHECK=1 make fmt, and git diff --check pass. This deliberately does not change existing alarm/setitimer interoperability, remaining-time accounting, or timer cancellation races. Signed-off-by: longjin <longjin@dragonos.org>
Member
Author
|
@codex review |
This was referenced Sep 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix
alarm(0)incorrectly arming an immediately expiring timer when the current alarm slot is empty. This unexpected SIGALRM can terminategit-upload-pack, causing local clone/fetch/pull to report early EOF or bad pack headers.Validation
Validation used x86_64 DragonOS in QEMU/KVM with two vCPUs and an ext4 root filesystem. Independent plan, implementation and test reviews found no blocking issues.
Scope
This is a focused fix for an empty alarm slot and zero seconds. It does not claim complete alarm/setitimer interoperability, remaining-time accounting or cancellation-race coverage. The full Git and full kernel test suites were not run.
Issue linkage
Fixes #2330. Parent LMbench blocker tracker: #2286.