Skip to content

Remove unneeded save-signal-mask FIXME#10

Open
gc00 wants to merge 1 commit into
mainfrom
signal-mask-fix-for-main
Open

Remove unneeded save-signal-mask FIXME#10
gc00 wants to merge 1 commit into
mainfrom
signal-mask-fix-for-main

Conversation

@gc00

@gc00 gc00 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

getcontext()/setcontext() already restore a thread's blocked-signal set via uc_sigmask, even across the raw clone() used to recreate a checkpointed thread. The thread_sigmask field and abort were unnecessary; both are removed.

Also drops BUG.README from version control.

Summary by CodeRabbit

  • Documentation
    • Removed outdated setup and command instructions from the bug reference notes.
  • Bug Fixes
    • Improved checkpoint and restore handling for thread signal masks, helping preserve blocked signals more reliably across process transitions.

getcontext()/setcontext() already restore a thread's blocked-signal
set via uc_sigmask, even across the raw clone() used to recreate a
checkpointed thread. The thread_sigmask field and abort were
unnecessary; both are removed.

Also drops BUG.README from version control.
@gc00 gc00 requested review from aayushi363 and maxwellpirtle July 7, 2026 04:23
@gc00 gc00 added the enhancement New feature or request label Jul 7, 2026
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Removes the manual per-thread signal mask field and associated save/restore/validation logic in dmtcp-callback.c, relying instead on ucontext_t's uc_sigmask for persisting blocked signals across getcontext()/setcontext(). Also clears all content from BUG.README.

Changes

Signal Mask Handling Simplification

Layer / File(s) Summary
Remove manual thread signal mask state and validation
src/lib/dmtcp-callback.c
Removes the thread_sigmask field from the threadinfo struct and eliminates the manual signal-blocking, mask computation, and abort-on-nonempty-mask logic in saveThreadStateBeforeFork()/child_setcontext_fast(), relying on ucontext_t's uc_sigmask instead.
Clear README content
BUG.README
Removes all previously documented environment setup and command instructions.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: removing the unnecessary signal-mask FIXME and related logic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch signal-mask-fix-for-main

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/dmtcp-callback.c`:
- Around line 126-130: The signal-mask handling around getcontext()/setcontext()
in dmtcp callback setup drops the required SIG_MULTITHREADED_FORK unblock on the
child resume path. Update the logic in child_setcontext_fast() and the related
context-saving path so the new thread restores the saved ucontext_t state
without leaving SIG_MULTITHREADED_FORK permanently blocked, preserving
multithreaded fork participation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 51795434-8ac1-4a22-9b5c-1ff5b5c3d425

📥 Commits

Reviewing files that changed from the base of the PR and between 7a2d504 and 40a21a6.

📒 Files selected for processing (2)
  • BUG.README
  • src/lib/dmtcp-callback.c
💤 Files with no reviewable changes (1)
  • BUG.README

Comment thread src/lib/dmtcp-callback.c
Comment on lines +126 to 130
// No manual signal-mask save/restore needed: getcontext()/setcontext()
// already save/restore the blocked-signal set via ucontext_t's uc_sigmask,
// even when setcontext() resumes on a brand-new clone()'d OS thread (see
// child_setcontext_fast() below).
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Locate getcontext call site, child resume path, and any SIG_MULTITHREADED_FORK (un)masking.
fd -t f 'dmtcp-callback.c' --exec rg -nP -C4 \
  'getcontext|setcontext|SIG_MULTITHREADED_FORK|sigdelset|pthread_sigmask|sigprocmask|child_setcontext_fast|thread_handle_after_dmtcp_restart' {}

# Cross-check the shared fork implementation for where the fork signal is unblocked.
fd -t f 'multithreaded_fork.c' --exec rg -nP -C3 \
  'SIG_MULTITHREADED_FORK|sigdelset|sigaddset|pthread_sigmask|sigprocmask|uc_sigmask' {}

Repository: mcminickpt/deep-debug

Length of output: 6625


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the relevant sections in both files with line numbers.
sed -n '225,255p' src/common/multithreaded_fork.c
printf '\n---\n'
sed -n '400,450p' src/common/multithreaded_fork.c
printf '\n---\n'
sed -n '110,145p' src/lib/dmtcp-callback.c

Repository: mcminickpt/deep-debug

Length of output: 4628


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Search for any explicit unblock/removal of SIG_MULTITHREADED_FORK on the child resume path.
rg -n "SIG_MULTITHREADED_FORK|pthread_sigmask|sigprocmask|sigdelset|sigaddset" src/lib/dmtcp-callback.c src/common/multithreaded_fork.c

Repository: mcminickpt/deep-debug

Length of output: 1435


Restore the SIG_MULTITHREADED_FORK mask handling

getcontext() runs inside the SIG_MULTITHREADED_FORK handler, so the saved uc_sigmask includes that signal blocked. child_setcontext_fast() restores that mask on the new thread, and there’s no explicit unblock on the child resume path. That can leave this thread unable to participate in a later multithreaded fork and hang the process.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/dmtcp-callback.c` around lines 126 - 130, The signal-mask handling
around getcontext()/setcontext() in dmtcp callback setup drops the required
SIG_MULTITHREADED_FORK unblock on the child resume path. Update the logic in
child_setcontext_fast() and the related context-saving path so the new thread
restores the saved ucontext_t state without leaving SIG_MULTITHREADED_FORK
permanently blocked, preserving multithreaded fork participation.

@xuyao0127 xuyao0127 requested a review from Copilot July 7, 2026 21:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@xuyao0127 xuyao0127 requested a review from Copilot July 7, 2026 21:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants