Skip to content

fix(time): keep alarm(0) disarmed when no timer exists - #2308

Merged
fslongjin merged 1 commit into
DragonOS-Community:masterfrom
fslongjin:codex/fix-alarm-zero-disarm
Sep 21, 2026
Merged

fslongjin merged 1 commit into
DragonOS-Community:masterfrom
fslongjin:codex/fix-alarm-zero-disarm

Conversation

@fslongjin

@fslongjin fslongjin commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Summary

Fix alarm(0) incorrectly arming an immediately expiring timer when the current alarm slot is empty. This unexpected SIGALRM can terminate git-upload-pack, causing local clone/fetch/pull to report early EOF or bad pack headers.

  • Return zero without creating a timer in the existing locked empty-slot branch.
  • Preserve nonzero alarms and existing cancellation/replacement paths.
  • Add four process-isolated dunitest regression cases and enable them in the whitelist.
  • Keep the fix at the syscall semantic boundary; no Git-specific behavior or generic timer changes.

Validation

Check Result
New tests on Linux 4/4 pass
New tests on pre-fix DragonOS Three zero-cancellation cases fail with SIGALRM; nonzero case passes
New tests on fixed DragonOS 4/4 pass, plus three additional consecutive runs
Adjacent poll timeout / POSIX relative timer cases 4/4 and 9/9 pass
Minimal alarm(0) reproducer Changes from SIGALRM termination to normal exit
Git 2.43.0 local transfer file:// clone and incremental pull pass; HEAD comparison and fsck pass
Previously failing local-path pull Updates successfully; object/content checks pass
Git operation controls commit, branch/merge, stash/restore, push, gc, archive and bundle pass
HTTPS shallow clone Clone, content check and fsck pass
Build and format make kernel, FMT_CHECK=1 make fmt and diff checks pass

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.

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>
@github-actions github-actions Bot added the Bug fix A bug is fixed in this pull request label Sep 21, 2026
@fslongjin

Copy link
Copy Markdown
Member Author

@codex review

@fslongjin
fslongjin merged commit a6f8b57 into DragonOS-Community:master Sep 21, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug fix A bug is fixed in this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(time): empty-slot alarm(0) arms an unwanted timer

1 participant