Skip to content

Fix macOS FFM open file limits - #3300

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:audit-open-file-limits
May 24, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:audit-open-file-limits

Conversation

@dbwiddis

@dbwiddis dbwiddis commented May 24, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Fix macOS FFM open file limit queries to treat getrlimit() return value 0 as success.
  • Strengthen current-process open file limit smoke coverage for JNA and FFM paths.

Fixes #3286

Summary by CodeRabbit

  • Bug Fixes

    • Corrected macOS handling of process open-file limits so soft and hard limits are retrieved reliably.
  • Tests

    • Strengthened tests to validate current process soft/hard open-file limits and to compare limits across implementations.
  • Chore

    • Updated changelog entry for the upcoming 7.2.0 release.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 24, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2fc08dbb-2020-49f5-a706-a72a5cfbaa9f

📥 Commits

Reviewing files that changed from the base of the PR and between a6824d6 and 6bf0c41.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • oshi-benchmark/src/test/java/oshi/comparison/NativeComparisonTest.java
  • oshi-core-ffm/src/main/java/oshi/software/os/mac/MacOSProcessFFM.java
  • oshi-core-ffm/src/test/java/oshi/ffm/OperatingSystemFFMTest.java
  • oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.java
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
📜 Recent review details
⏰ 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). (13)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 11, windows-latest
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 11, macos-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Analyze (java)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: JMH Benchmarks, ubuntu-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: JMH Benchmarks, windows-latest
🔇 Additional comments (4)
oshi-core-ffm/src/main/java/oshi/software/os/mac/MacOSProcessFFM.java (1)

406-407: LGTM!

Also applies to: 421-423

oshi-core-ffm/src/test/java/oshi/ffm/OperatingSystemFFMTest.java (1)

10-10: LGTM!

Also applies to: 24-24, 42-52

oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.java (1)

172-177: LGTM!

oshi-benchmark/src/test/java/oshi/comparison/NativeComparisonTest.java (1)

397-398: LGTM!


📝 Walkthrough

Walkthrough

macOS FFM now treats getrlimit() return value 0 as success for soft/hard open-file limit readers; tests were added and tightened to assert the current process soft limit is positive and the hard limit is >= soft, and FFM vs JNA comparisons were added. CHANGELOG updated.

Changes

macOS FFM Open File Limits Fix

Layer / File(s) Summary
FFM getrlimit success condition fix
oshi-core-ffm/src/main/java/oshi/software/os/mac/MacOSProcessFFM.java
getSoftOpenFileLimit() and getHardOpenFileLimit() now treat getrlimit(...) success as == 0 and read RLIM_CUR / RLIM_MAX from the buffer on success.
Test validation and assertions
oshi-core-ffm/src/test/java/oshi/ffm/OperatingSystemFFMTest.java, oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.java, oshi-benchmark/src/test/java/oshi/comparison/NativeComparisonTest.java, CHANGELOG.md
Added FFM test testCurrentProcessOpenFileLimits (soft > 0, hard >= soft); updated shared test to require positive soft limit and hard >= soft; added FFM vs JNA assertions for soft/hard limits; added matcher/import and changelog bullet for PR #3300.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • oshi/oshi#3287: Related macOS FFM getrlimit changes — refactors to use ForeignFunctions.callInArenaLongOrDefault and touches the same methods.
  • oshi/oshi#3150: Related work on current-process open-file descriptor handling and comparisons between native implementations.

Poem

🐰 A rabbit hops by, with nimble wit,
"Zero is success" — I softly knit.
On macOS the limits now are right,
Soft climbs up, hard holds tight.
Tests clap their paws and cheer the fix.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing macOS FFM open file limits by correcting the getrlimit() success condition.
Linked Issues check ✅ Passed The PR directly addresses all key objectives from issue #3286: fixes the macOS FFM getrlimit() success check [#3286], strengthens test coverage for current-process limits [#3286], and adds FFM-vs-JNA comparison tests [#3286].
Out of Scope Changes check ✅ Passed All changes are directly scoped to the linked issue objectives: macOS FFM fix, test coverage improvements, and JNA/FFM comparison tests; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📋 Issue Planner

Built with CodeRabbit's Coding Plans for faster development and fewer bugs.

View plan used: #3286

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@codecov

codecov Bot commented May 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.66%. Comparing base (5721f32) to head (6bf0c41).

Files with missing lines Patch % Lines
...ain/java/oshi/software/os/mac/MacOSProcessFFM.java 0.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3300      +/-   ##
============================================
+ Coverage     75.58%   75.66%   +0.07%     
  Complexity       76       76              
============================================
  Files           410      410              
  Lines         15830    15830              
  Branches       2546     2546              
============================================
+ Hits          11965    11977      +12     
+ Misses         2375     2354      -21     
- Partials       1490     1499       +9     
Flag Coverage Δ
linux 40.27% <0.00%> (+0.06%) ⬆️
macos 40.82% <0.00%> (+0.05%) ⬆️
windows 48.57% <0.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dbwiddis
dbwiddis force-pushed the audit-open-file-limits branch from a6824d6 to 6bf0c41 Compare May 24, 2026 22:29
@dbwiddis
dbwiddis merged commit e016564 into oshi:master May 24, 2026
19 checks passed
@dbwiddis
dbwiddis deleted the audit-open-file-limits branch May 24, 2026 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Audit and test OSProcess open file limit implementations

1 participant