Skip to content

Fixed SYS_close_range in syscall wrapper#1218

Merged
xuyao0127 merged 1 commit intodmtcp:mainfrom
xuyao0127:close-range-wrapper-fix
Sep 17, 2025
Merged

Fixed SYS_close_range in syscall wrapper#1218
xuyao0127 merged 1 commit intodmtcp:mainfrom
xuyao0127:close-range-wrapper-fix

Conversation

@xuyao0127
Copy link
Copy Markdown
Collaborator

@xuyao0127 xuyao0127 commented Sep 17, 2025

This is a follow up of PR #1210. On Khoury Login, SYS_close_range is defined, although the close_range() syscall is not available. Therefore, I added the version check before using close_range() in the syscall() wrapper.

Summary by CodeRabbit

  • New Features
    • None.
  • Bug Fixes
    • Improved Linux compatibility by enabling close-range handling only on systems with Linux kernel 5.9+ and GLIBC 2.34+, preventing errors on older environments.
  • Chores
    • Updated platform checks to align system call usage with supported OS and library versions, enhancing stability across distributions.

@xuyao0127 xuyao0127 requested review from gc00 and karya0 September 17, 2025 19:58
@xuyao0127 xuyao0127 added the bug label Sep 17, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Sep 17, 2025

Walkthrough

Adjusted a preprocessor condition in src/miscwrappers.cpp to compile the SYS_close_range handling only when building against Linux kernel 5.9+ and GLIBC 2.34+. The runtime logic inside the case remains unchanged.

Changes

Cohort / File(s) Summary
Build-time guard update
src/miscwrappers.cpp
Replaced #ifdef SYS_close_range with #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0) && __GLIBC_PREREQ(2, 34) around the SYS_close_range case; internal logic unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitch my whiskers, kernels align,
5.9’s gate with 2.34—so fine.
Compile-time paths neatly rearranged,
No runtime hops, just guards exchanged.
In burrows of code where syscalls range,
This rabbit nods: a crisp, clean change. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Fixed SYS_close_range in syscall wrapper" is a concise, single-sentence summary that directly reflects the primary change—correcting SYS_close_range handling in the syscall wrapper to avoid invoking an unavailable syscall. It is specific to the change and not generic or noisy, and it aligns with the PR description about adding a version guard. A teammate scanning history should understand the main intent from this title alone.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/miscwrappers.cpp (1)

347-354: Tighten the guard and match the official signature.

  • Prefer checking the syscall macro plus glibc version instead of LINUX_VERSION_CODE (kernel header version is a poor proxy in userland).
  • Use unsigned int for fd1/fd2 to match glibc’s close_range prototype.

Apply this diff within this block:

-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0) && __GLIBC_PREREQ(2, 34)
+#if defined(SYS_close_range) && __GLIBC_PREREQ(2, 34)
   case SYS_close_range:
   {
-    SYSCALL_GET_ARGS_3(int, fd1, int, fd2, unsigned int, flags);
+    SYSCALL_GET_ARGS_3(unsigned int, fd1, unsigned int, fd2, unsigned int, flags);
     ret = close_range(fd1, fd2, flags);
     break;
   }
 #endif

Also, since you don’t use CLOSE_RANGE_* here, consider dropping the #include <linux/close_range.h> at Lines 46–50 to avoid a hard dependency on kernel UAPI headers. If needed elsewhere, gate it with __has_include(<linux/close_range.h>).

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d3d2a0d and 83ac6e5.

📒 Files selected for processing (1)
  • src/miscwrappers.cpp (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (1)
src/miscwrappers.cpp (1)

347-354: Good fix: avoid building the case when glibc lacks close_range().

This prevents compile/link issues on systems where SYS_close_range exists but the libc wrapper does not.

@gc00
Copy link
Copy Markdown
Contributor

gc00 commented Sep 17, 2025

@xuyao0127 , Thanks for fixing this. This bug was preventing DMTCP from compiling on Rocky Linux 8 (an older distro).

Copy link
Copy Markdown
Contributor

@gc00 gc00 left a comment

Choose a reason for hiding this comment

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

LGTM.

@xuyao0127 xuyao0127 merged commit cf0541f into dmtcp:main Sep 17, 2025
2 checks passed
@xuyao0127 xuyao0127 deleted the close-range-wrapper-fix branch September 17, 2025 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants