Skip to content

Fix three JNA/FFM twin divergences on the file-system and network paths - #3569

Merged
dbwiddis merged 2 commits into
oshi:masterfrom
dbwiddis:fix-twin-divergences-3569
Aug 3, 2026
Merged

dbwiddis merged 2 commits into
oshi:masterfrom
dbwiddis:fix-twin-divergences-3569

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Aug 3, 2026 •

Copy link
Copy Markdown
Member

Found by a normalized set-difference sweep over the JNA/FFM twin pairs — stripping the JNA/FFM suffixes, reducing each side to its logic lines, and comm-ing the two. This surfaces divergences that duplication detection structurally cannot: a duplicate-block matcher discards exactly the differing lines, which is where these bugs live. All three are edge-case guards present on one twin and missing (or misconfigured) on the other; none is reachable on the happy path, which is why they survived.

1. macOS FFM file store — dead DiskArbitration null guard

MacFileSystemFFM guarded the DiskArbitration session with session.segment() == null. DASessionCreate is an ADDRESS downcall, so on failure it returns MemorySegment.NULL, never Java null — the guard was dead and the "Unable to open session" bail never fired. This was the only segment() == null in the whole FFM module; the sibling MacHWDiskStoreFFM already uses isNull(). The JNA twin bails correctly. Fixed to session.isNull().

2. Windows file system — mount-point list buffer overflow

A volume whose mount-point list exceeds the buffer was dropped from the results:

  • JNA (WindowsFileSystemJNA) had no retry at all and passed null for the return-length pointer. Now retries once with a right-sized buffer on ERROR_MORE_DATA.
  • FFM (WindowsFileSystemFFM) had a retry, but keyed it on 0x7A (ERROR_INSUFFICIENT_BUFFER), whereas GetVolumePathNamesForVolumeName reports a short buffer with ERROR_MORE_DATA (234) — so its retry never fired either. Now uses the correct named constant.

3. Windows FFM TCP/UDP connections — no size-race retry

IPHlpAPIUtilFFM's four connection queries sized once then fetched once, throwing Win32Exception on ERROR_INSUFFICIENT_BUFFER. Under connection churn the table can grow between the two calls, transiently reporting no connections for that family. The JNA twin loops on ERROR_INSUFFICIENT_BUFFER; the FFM queries now do the same.

Verification

Built and tested on macOS (JDK 25+ toolchain, so the FFM module is compiled): spotless:apply, checkstyle:check, install (tests green), and forbiddenapis:check all pass on oshi-core/oshi-core-ffm. The Windows paths compile but are not executable from this host; CI covers Windows. The javadoc:javadoc aggregator step fails identically on clean master (a named/unnamed-module reactor-composition issue, unrelated to these changes, which add only line comments).

Summary by CodeRabbit

  • Bug Fixes
    • Improved macOS file-system session failure handling.
    • Improved Windows volume and mount-path enumeration when additional buffer space is required.
    • Added bounded retries for Windows TCP and UDP connection queries when data exceeds the initial buffer size.
    • Prevented repeated retry attempts from continuing indefinitely during Windows network connection queries.
    • Standardized Windows error handling for volume path and network connection operations.

Found by a normalized set-difference sweep over the JNA/FFM twin pairs,
which surfaces divergences that duplication detection structurally cannot
(the differing lines are exactly what a duplicate-block matcher discards).

- MacFileSystemFFM: the DiskArbitration session guard tested the returned
  foreign pointer for Java null. DASessionCreate is an ADDRESS downcall, so
  it yields MemorySegment.NULL on failure and never Java null; the guard was
  dead and the "unable to open session" bail never fired. Use isNull(),
  matching the sibling MacHWDiskStoreFFM.

- WindowsFileSystem: a volume whose mount-point list overflows the buffer
  was dropped. The JNA twin had no retry at all; the FFM twin retried but
  keyed on 0x7A (ERROR_INSUFFICIENT_BUFFER) whereas
  GetVolumePathNamesForVolumeName reports a short buffer with
  ERROR_MORE_DATA (234), so its retry never fired either. JNA now retries
  with a right-sized buffer on ERROR_MORE_DATA, and FFM uses the correct
  named constant.

- IPHlpAPIUtilFFM: the TCP/UDP connection queries sized once then fetched
  once, throwing Win32Exception on ERROR_INSUFFICIENT_BUFFER. Under
  connection churn the table can grow between the two calls, transiently
  reporting no connections for a family. Retry on ERROR_INSUFFICIENT_BUFFER
  with the newly reported size, matching the JNA do/while loop.
@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 34703fd4-d066-4635-8a15-7757277356e3

📥 Commits

Reviewing files that changed from the base of the PR and between 2a8077b and 6ac2957.

📒 Files selected for processing (2)
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.java
📜 Recent review details
⏰ Context from checks skipped due to timeout. (8)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Analyze (java)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 26, ubuntu-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Test JDK 21, ubuntu-latest
🧰 Additional context used
📓 Path-based instructions (3)
oshi-core/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

oshi-core/src/main/java/**/*.java: oshi-core must compile with Java 8; do not use modern features such as var, records, switch expressions, text blocks, List.of, or Stream.toList().
Behavior changes in JNA implementation classes should also be applied equivalently to their corresponding FFM twins, unless the difference is intentionally specific to JNA or FFM.

Files:

  • oshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.java
**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

**/*.java: Do not use org.slf4j.event.**; use oshi.util.LogLevel instead.
Add the imports needed by code, and let Spotless own formatting and import ordering.
Verify native struct offsets, field widths, and sysctl/ioctl constants against the target operating system's real headers rather than inferring them from another OS.

Files:

  • oshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.java
**/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

**/src/main/java/**/*.java: Every public member must have Javadoc, and code and Javadoc—including {@link ...}—must use imported simple class names rather than fully qualified names.
New classes should declare an appropriate concurrency annotation from oshi.annotation.concurrent, matching the modeled class when applicable.
Memoize constant or expensive, slowly changing system-call results with oshi.util.Memoizer, following surrounding patterns and using defaultExpiration() when values must refresh.
Place reusable per-OS acquisition and parsing helpers in oshi/driver/<os>/; keep parsing logic out of HAL classes where practical.
Prefer native calls for system information; on Linux prefer FileUtil for /proc and /sys, while on other platforms ExecutingCommand is acceptable when native APIs do not expose the information.
Do not commit generated output, target/, or IDE files.

Files:

  • oshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.java
🧠 Learnings (4)
📚 Learning: 2026-04-06T04:45:47.644Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:47.644Z
Learning: In the oshi/oshi project, only interfaces and classes in the root packages `oshi`, `oshi.hardware`, and `oshi.software.os` are considered the public API. Code in subpackages that represent specific implementations/platforms (e.g., `oshi.software.os.linux`, `oshi.hardware.platform.linux`, and similar subpackages) is implementation detail. When reviewing, do not treat changes to classes in these platform-specific subpackages as public API breaks (for example: making `LinuxOperatingSystem` abstract, narrowing constructor visibility, or adding/removing abstract methods should not be flagged as breaking public API).

Applied to files:

  • oshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.java
📚 Learning: 2026-07-06T19:25:59.225Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:25:59.225Z
Learning: In this repo’s SLF4J 1.x-compatible logging code, do not flag cases where a logger call uses SLF4J 1.6+ implicit-cause handling—e.g., `log.error("...{}", value, t)` (or similar with a single `{}` placeholder) where `t` is passed as the final/trailing argument. SLF4J will attach `t` as the log event’s cause with the full stack trace; this is equivalent to SLF4J 2.x’s fluent `atLevel(...).setCause(t).log(...)` and is intentionally used to preserve SLF4J 1.x runtime compatibility.

Applied to files:

  • oshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.java
📚 Learning: 2026-07-30T00:35:22.638Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3547
File: oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdFirmware.java:82-82
Timestamp: 2026-07-30T00:35:22.638Z
Learning: In OSHI, treat changes as “API-breaking” only when they affect classes (or relevant API surface) annotated with `PublicAPI`. Public classes/members that are not annotated with `PublicAPI` should be reviewed as internal implementation details, even if they are public (e.g., classes like `oshi.hardware.common.platform.unix.BsdFirmware`). Also, respect intentional visibility decisions used for tests—e.g., methods like `BsdFirmware.parseDmesg(List<String>)` may be intentionally package-private to support tests within the same package; avoid widening visibility or altering signatures unless the related `PublicAPI` contract requires it.

Applied to files:

  • oshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.java
📚 Learning: 2026-08-03T00:46:14.953Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3566
File: oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdNetworkParams.java:18-22
Timestamp: 2026-08-03T00:46:14.953Z
Learning: In the OSHI Java codebase, do not require duplicate Javadoc on public methods annotated with Override when the inherited Javadoc from the parent declaration adequately documents the method. The general public-member Javadoc requirement should not flag these overrides solely because they lack redundant documentation.

Applied to files:

  • oshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.java
🔇 Additional comments (1)
oshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.java (1)

58-64: LGTM!

Also applies to: 123-134, 162-173, 200-211, 237-248


📝 Walkthrough

Walkthrough

The changes update macOS Disk Arbitration session validation and Windows volume and connection-table buffer handling. Windows FFM and JNA networking paths now use bounded retries. Windows volume paths retry with reported buffer sizes.

Changes

Platform error handling

Layer / File(s) Summary
macOS session validation
oshi-core-ffm/src/main/java/oshi/software/os/mac/MacFileSystemFFM.java
Uses session.isNull() to validate the Disk Arbitration session.
Windows volume path retries
oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java, oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
Uses named error constants for ERROR_MORE_DATA. The JNA path resizes the buffer from the reported required length before retrying.
Windows connection query retries
oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.java, oshi-core/src/main/java/oshi/software/os/windows/WindowsInternetProtocolStatsJNA.java, CHANGELOG.md
Bounds TCP and UDP table retries to five attempts after ERROR_INSUFFICIENT_BUFFER. Adds the 7.4.4 changelog entry.

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

Possibly related PRs

Poem

A rabbit checks the session state,
Then grows each buffer to its rate.
TCP and UDP retry with care,
Five attempts keep the calls aware.
Windows volumes complete their way.
“Hopfully robust!” I say.

🚥 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 clearly and concisely summarizes the three JNA/FFM divergence fixes in the file-system and network paths.
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 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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
`@oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.java`:
- Around line 209-215: Bound the ERROR_INSUFFICIENT_BUFFER retry loops in the
TCP and UDP GetExtended*Table query blocks, including the paths around the
visible TCP loop and corresponding UDP flows. Limit retries to a small fixed
maximum, then exit through the existing default/failure return behavior when the
limit is exhausted, while preserving allocation and retry behavior for attempts
within the bound.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cac25259-cf0b-4c15-8ad4-04ed59c14513

📥 Commits

Reviewing files that changed from the base of the PR and between 27ee25f and 2a8077b.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/mac/MacFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
📜 Review details
⏰ Context from checks skipped due to timeout. (5)
  • GitHub Check: Analyze (java)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

**/*.java: Do not use org.slf4j.event.**; use oshi.util.LogLevel instead.
Add the imports needed by code, and let Spotless own formatting and import ordering.
Verify native struct offsets, field widths, and sysctl/ioctl constants against the target operating system's real headers rather than inferring them from another OS.

Files:

  • oshi-core-ffm/src/main/java/oshi/software/os/mac/MacFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
oshi-core-ffm/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

oshi-core-ffm/src/main/java/**/*.java: oshi-core-ffm must not reference com.sun.jna.**.
Behavior changes in FFM implementation classes should also be applied equivalently to their corresponding JNA twins, unless the difference is intentionally specific to FFM or JNA.

Files:

  • oshi-core-ffm/src/main/java/oshi/software/os/mac/MacFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.java
**/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

**/src/main/java/**/*.java: Every public member must have Javadoc, and code and Javadoc—including {@link ...}—must use imported simple class names rather than fully qualified names.
New classes should declare an appropriate concurrency annotation from oshi.annotation.concurrent, matching the modeled class when applicable.
Memoize constant or expensive, slowly changing system-call results with oshi.util.Memoizer, following surrounding patterns and using defaultExpiration() when values must refresh.
Place reusable per-OS acquisition and parsing helpers in oshi/driver/<os>/; keep parsing logic out of HAL classes where practical.
Prefer native calls for system information; on Linux prefer FileUtil for /proc and /sys, while on other platforms ExecutingCommand is acceptable when native APIs do not expose the information.
Do not commit generated output, target/, or IDE files.

Files:

  • oshi-core-ffm/src/main/java/oshi/software/os/mac/MacFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
oshi-core/src/main/java/**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

oshi-core/src/main/java/**/*.java: oshi-core must compile with Java 8; do not use modern features such as var, records, switch expressions, text blocks, List.of, or Stream.toList().
Behavior changes in JNA implementation classes should also be applied equivalently to their corresponding FFM twins, unless the difference is intentionally specific to JNA or FFM.

Files:

  • oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
🧠 Learnings (5)
📚 Learning: 2026-07-06T19:25:59.225Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:25:59.225Z
Learning: In this repo’s SLF4J 1.x-compatible logging code, do not flag cases where a logger call uses SLF4J 1.6+ implicit-cause handling—e.g., `log.error("...{}", value, t)` (or similar with a single `{}` placeholder) where `t` is passed as the final/trailing argument. SLF4J will attach `t` as the log event’s cause with the full stack trace; this is equivalent to SLF4J 2.x’s fluent `atLevel(...).setCause(t).log(...)` and is intentionally used to preserve SLF4J 1.x runtime compatibility.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/software/os/mac/MacFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
📚 Learning: 2026-07-30T00:35:22.638Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3547
File: oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdFirmware.java:82-82
Timestamp: 2026-07-30T00:35:22.638Z
Learning: In OSHI, treat changes as “API-breaking” only when they affect classes (or relevant API surface) annotated with `PublicAPI`. Public classes/members that are not annotated with `PublicAPI` should be reviewed as internal implementation details, even if they are public (e.g., classes like `oshi.hardware.common.platform.unix.BsdFirmware`). Also, respect intentional visibility decisions used for tests—e.g., methods like `BsdFirmware.parseDmesg(List<String>)` may be intentionally package-private to support tests within the same package; avoid widening visibility or altering signatures unless the related `PublicAPI` contract requires it.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/software/os/mac/MacFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
📚 Learning: 2026-08-02T23:56:23.866Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3565
File: oshi-core-ffm/src/main/java/oshi/ffm/platform/unix/PosixLibcFunctions.java:51-56
Timestamp: 2026-08-02T23:56:23.866Z
Learning: For Java FFM bindings in the oshi-core-ffm module, assume a 64-bit JVM and 64-bit operating system. Do not flag 32-bit native ABI or memory-layout compatibility concerns, consistent with the project's JDK 25 support policy, unless that policy changes.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/software/os/mac/MacFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.java
📚 Learning: 2026-08-03T00:46:14.953Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3566
File: oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdNetworkParams.java:18-22
Timestamp: 2026-08-03T00:46:14.953Z
Learning: In the OSHI Java codebase, do not require duplicate Javadoc on public methods annotated with Override when the inherited Javadoc from the parent declaration adequately documents the method. The general public-member Javadoc requirement should not flag these overrides solely because they lack redundant documentation.

Applied to files:

  • oshi-core-ffm/src/main/java/oshi/software/os/mac/MacFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java
  • oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.java
  • oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
📚 Learning: 2026-04-06T04:45:47.644Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:47.644Z
Learning: In the oshi/oshi project, only interfaces and classes in the root packages `oshi`, `oshi.hardware`, and `oshi.software.os` are considered the public API. Code in subpackages that represent specific implementations/platforms (e.g., `oshi.software.os.linux`, `oshi.hardware.platform.linux`, and similar subpackages) is implementation detail. When reviewing, do not treat changes to classes in these platform-specific subpackages as public API breaks (for example: making `LinuxOperatingSystem` abstract, narrowing constructor visibility, or adding/removing abstract methods should not be flagged as breaking public API).

Applied to files:

  • oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java
🔇 Additional comments (4)
oshi-core-ffm/src/main/java/oshi/software/os/mac/MacFileSystemFFM.java (1)

88-88: LGTM!

oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsFileSystemFFM.java (1)

33-33: LGTM!

Also applies to: 182-185

oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystemJNA.java (1)

17-17: LGTM!

Also applies to: 154-181

CHANGELOG.md (1)

10-10: LGTM!

@codecov

codecov Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 17.64706% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.45%. Comparing base (27ee25f) to head (6ac2957).

Files with missing lines Patch % Lines
...shi/ffm/util/platform/windows/IPHlpAPIUtilFFM.java 0.00% 12 Missing and 4 partials ⚠️
...oshi/software/os/windows/WindowsFileSystemJNA.java 25.00% 5 Missing and 1 partial ⚠️
...re/os/windows/WindowsInternetProtocolStatsJNA.java 50.00% 0 Missing and 4 partials ⚠️
...in/java/oshi/software/os/mac/MacFileSystemFFM.java 0.00% 0 Missing and 1 partial ⚠️
...oshi/software/os/windows/WindowsFileSystemFFM.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3569      +/-   ##
============================================
- Coverage     79.57%   79.45%   -0.12%     
  Complexity     3814     3814              
============================================
  Files           709      709              
  Lines         24223    24248      +25     
  Branches       4046     4052       +6     
============================================
- Hits          19276    19267       -9     
- Misses         2766     2790      +24     
- Partials       2181     2191      +10     
Flag Coverage Δ
linux 36.93% <0.00%> (-0.03%) ⬇️
macos 37.85% <0.00%> (-0.11%) ⬇️
windows 44.67% <17.64%> (-0.03%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 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.

The ERROR_INSUFFICIENT_BUFFER retry added for the Windows FFM TCP/UDP
connection queries was unbounded. The table only reallocates when it has
genuinely outgrown the just-measured size, so it is not a spin, but a table
under sustained churn could reallocate from the confined arena repeatedly
without freeing the prior buffer. Cap it at 5 retries; when exhausted, ret
stays ERROR_INSUFFICIENT_BUFFER and the existing failure path returns the
empty list.

Apply the same bound to the JNA twin's four do/while loops so the two
implementations stay consistent (the divergence class this PR exists to
close). Both sides now allow one fetch plus at most five retries.
@dbwiddis
dbwiddis merged commit 8cbe88f into oshi:master Aug 3, 2026
17 checks passed
@dbwiddis
dbwiddis deleted the fix-twin-divergences-3569 branch August 3, 2026 17:20
dbwiddis added a commit that referenced this pull request Aug 4, 2026
The monotonic() clamps added in #3574 are read-modify-writes on volatile
long fields, which Sonar flags as S3078. The read-modify-write is one of
~20 unsynchronized volatile writes in updateAttributes(); OSProcess
documents that concurrent callers must synchronize externally, and both
racing writers only ever raise the value, so a lost clamp still yields a
real ps reading. Suppress on the two methods rather than convert the
shared protected fields to AtomicLong.

Also restore ascending PR-number order in the 7.4.4 changelog, where the
#3574 squash-merge landed the entry above #3569 and #3573.
dbwiddis added a commit that referenced this pull request Aug 4, 2026
…3582)

* Retry the AIX perfstat_process fill when the buffer filled exactly

perfstat_process is a count-then-fill pair, and it returns its array
sorted by pid, so a buffer sized from the first call loses the
highest-pid entries when processes spawn in between. The entry lost is
most often the calling JVM's own, which is the newest process in the
list. Both twins padded the allocation by 10 to absorb that churn, which
is a guess rather than a guarantee.

Observed on the shared cfarm AIX host: five NativeComparisonTest cases
failed together on both attempts of one run, all of them rooted in
getProcess(getProcessId()) returning null, and the same commit passed on
a re-run minutes later. Under a busy box more than 10 processes appeared
between the two calls.

Treat a return equal to the allocation as possible truncation: re-count
and retry, bounded at 3 attempts, after which the result is returned as
is because a short list still beats none. Also raise the pad from 10 to
64, which costs a few KB of a confined arena and makes the retry a rare
path rather than the common one.

Applied to both backends. This is the count-then-fetch race class that
#3569 fixed for the Windows connection tables, in a different API.

Not reproducible off AIX, and load-dependent even there, so CI passing
does not confirm the fix; it confirms no regression. The reasoning rests
on the perfstat contract and the sorted-by-pid ordering the previous
comment already documented.

* Keep the full buffer when the perfstat re-count fails

The truncation retry re-counted the processes to size the next attempt,
and assigned that straight back to the loop variable. A re-count that
returns zero or an error then failed the loop guard, so the method fell
out and returned an empty array -- discarding the full buffer of entries
it had just read successfully.

That is worse than the behavior this PR set out to fix: a list that may be
missing its tail became no list at all, on a path reachable whenever
perfstat transiently fails between two calls.

Hold the re-count in a local and only retry when it is positive.
Otherwise fall through and map the buffer already in hand, which is the
same result the code produced before the retry existed.

Both twins.

* Scale the perfstat pad with the process count, with a floor

The slack absorbs processes spawned between the count and fill calls, so
what it needs to track is the system's spawn rate, not its process count.
Those correlate weakly, and the two cases pull opposite ways.

A small, busy host churns faster than any proportional pad would cover:
at 200 processes a 10% pad is 20 entries, fewer than the fixed 64, and
this is the shape of host that produced the original failure. A large host
makes that same fixed 64 thin — 1.3% headroom at 5000 processes — where a
proportional term is the one that helps.

So take whichever is larger: count/10 or 64. Extracted as paddedSize() in
both twins with the reasoning recorded, since neither half is redundant.

Cost is immaterial either way. perfstat_process_t is 288 bytes, so the
proportional term adds 144 KB at 5000 processes, and the retry loop is
what provides correctness — the pad only decides how often that retry has
to run.
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.

1 participant