Skip to content

fix(nid): report failed library writes - #6906

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
Zinebyte:fix/nid-write-errors
Oct 19, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
Zinebyte:fix/nid-write-errors

Conversation

@Zinebyte

@Zinebyte Zinebyte commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What

The NID patcher reports OK and exits 0 when a library write fails after opening the output. A valid 13,576-byte shared library restricted to a 1,024-byte output is truncated to 1,024 bytes while the tool reports success, allowing a build to continue with an incomplete library.

Explicitly close the output stream and check its state before reporting success. Write or final flush failures now use the existing FAIL diagnostic and exit status 2. File writes retain the current in-place behavior, so a failed write can still leave partial output.

Tested

Linux x86-64, GCC/G++ 13.3, glibc 2.39, main d9b696ddbb. Built the actual nid_patcher from all nine sources listed by its CMake target, with C++20 and O2. An unrestricted native GNU-hash shared library patches and returns 42 through its NID export. With a child-only RLIMIT_FSIZE and ignored SIGXFSZ, unchanged main reports success after the short write.

The registered native-path regression adds zero-byte and partial-write failure cases. Both fail against the unchanged actual tool and pass with the fix: exit 2, filename/error diagnostic, no success message. Existing Unicode paths, export-reference preservation and missing-input controls pass. All eight applicable NID Python test groups pass, and independent review reproduced the new red/green cases. The output-limit cases are POSIX-only; the stream-state fix is portable C++. Conventions and whitespace checks pass. No full-runtime or retail-title execution is claimed. The open-PR inventory and #6901's actual source contain no competing write-error fix.

Combined validation with #6904 also passes: both commits merge cleanly, the rebuilt actual tool passes all eight applicable NID groups, native SysV/dual-hash export lookup controls and zero/partial-write error controls.

Checklist

  • Based on current main; no other open PR implements the same fix
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@adriadam10 adriadam10 self-assigned this Oct 19, 2026
@adriadam10
adriadam10 merged commit c562814 into boykopovar:main Oct 19, 2026
9 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the stream-state fix in _writeFile (the callers already turn the exception into FAIL / exit 2), and that the new zero-byte and partial-write cases only pass with the change and are registered in ctest (nid_patcher_native_paths); merged.

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.

2 participants