Skip to content

Fix the Windows file save encoding and a HarfBuzz use-after-free - #173

Merged
balazs-szucs merged 6 commits into
Stirling-Tools:mainfrom
balazs-szucs:fix/windows-binary-save
Oct 19, 2026
Merged

balazs-szucs merged 6 commits into
Stirling-Tools:mainfrom
balazs-szucs:fix/windows-binary-save

Conversation

@balazs-szucs

@balazs-szucs balazs-szucs commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

No description provided.

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

An error occurred during the review process. Please try again later.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: Stirling-Tools/JPDFium/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: f3187795-41ca-4c51-b46d-4a84278e9376
📥 Commits

Reviewing files that changed from the base of the PR and between 2f87a36 and 63a5f59.

📒 Files selected for processing: 3
  • .github/workflows/publish-github-packages.yml
  • .github/workflows/release.yml
  • jpdfium/src/test/java/stirling/software/jpdfium/SaveEncodingNativeSmokeTest.java

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout: 17
  • GitHub Check: Corpus tests (shard 3/4)
  • GitHub Check: Corpus tests (shard 0/4)
  • GitHub Check: Corpus tests (shard 1/4)
  • GitHub Check: Corpus tests (shard 2/4)
  • GitHub Check: build-natives (linux-musl-arm64, ubuntu-24.04-arm, musl)
  • GitHub Check: build-natives (windows-arm64, windows-11-arm)
  • GitHub Check: build-natives (linux-x64, ubuntu-latest)
  • GitHub Check: build-natives (darwin-arm64, macos-14)
  • GitHub Check: build-natives (windows-x64, windows-latest)
  • GitHub Check: build-natives (linux-arm64, ubuntu-24.04-arm)
  • GitHub Check: build-natives (linux-musl-x64, ubuntu-latest, musl)
  • GitHub Check: build-natives (darwin-x64, macos-15-intel)
  • GitHub Check: JMH Benchmarks (FFM Downcall Overhead Gate)
  • GitHub Check: Build & Verify (Compilation) (macos-14)
  • GitHub Check: Native bridge libFuzzer (ASan/UBSan, real PDFium)
  • GitHub Check: CLI correctness & no-corruption tests
  • GitHub Check: Version bump script regression tests
🧰 Additional context used
📚 Code guidelines: 1
.github/CODERABBIT_REVIEW.md — configured
📓 Path-based instructions: 3
Enforce meaningful assertions, deterministic concurrency, failure-path cleanup, and explicit native/stub requirements.

⚙️ CodeRabbit configuration file

Files:

  • jpdfium/src/test/java/stirling/software/jpdfium/SaveEncodingNativeSmokeTest.java
Apply the Java 25 and FFM rules from .github/CODERABBIT_REVIEW.md.

⚙️ CodeRabbit configuration file

Files:

  • jpdfium/src/test/java/stirling/software/jpdfium/SaveEncodingNativeSmokeTest.java
Source excerpt: Use imports rather than package-qualified type names in method bodies and signatures.

📄 CodeRabbit inference engine (.github/CODERABBIT_REVIEW.md)

Files:

  • jpdfium/src/test/java/stirling/software/jpdfium/SaveEncodingNativeSmokeTest.java
🔇 Additional comments: 1
.github/workflows/publish-github-packages.yml: 1

317-317: 🎯 Functional Correctness

The omission is refuted for both workflows. Each runs setup-freebsd-sysroot.sh before the gate, and that script requires libunibreak and validates usr/lib/libunibreak.so. A missing libunibreak cannot reach the current gate and then fail the FreeBSD build. Adding it to the pkg-config probe is not supported by the inspected workflow.

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Fixed Windows file-based saves that could alter PDF data and cause page content to appear empty when reopened. The issue affected all file-based save options; saved files now preserve their original byte layout.
    • Fixed a Windows redaction issue involving font data that could interfere with redaction. Redacted documents now retain the expected text-removal behavior when reopened.

Windows staging-file opens now use binary mode. Native smoke tests compare file and memory saves and check reopened content, including after redaction. HarfBuzz now copies font data used during redaction. FreeBSD workflows check for required cross-build dependencies before continuing.

Changes: Windows File Saves

Layer / File(s) Summary
Binary staging and save validation
native/bridge/src/jpdfium_document.cpp, native/bridge/src/jpdfium_stub.cpp, jpdfium/src/test/java/stirling/software/jpdfium/SaveEncodingNativeSmokeTest.java, CHANGELOG.md
Both Windows staging-file open functions add _O_BINARY. Native smoke tests compare file and memory output and check reopened text, including after redaction. The changelog describes the newline conversion and affected save paths.

Redaction Font Data

Layer / File(s) Summary
HarfBuzz font-data ownership
native/bridge/src/jpdfium_redact_pattern.cpp, CHANGELOG.md
The HarfBuzz blob duplicates font bytes instead of relying on the local buffer after the function returns. The changelog records this redaction fix.

FreeBSD Build Checks

Layer / File(s) Summary
FreeBSD dependency checks
.github/workflows/publish-github-packages.yml, .github/workflows/release.yml
Both workflows check for required packages in the FreeBSD sysroot. When a dependency is unavailable, the workflow marks FreeBSD natives missing and exits successfully.

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 63a5f

No actionable merge-blocking risk remains from the reviewed changes. Normal checks can proceed.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Description check Inconclusive No pull request description was provided, so its relation to the changeset cannot be assessed. Add a concise description that summarizes the Windows file-save fix, the HarfBuzz lifetime fix, and the related tests or workflow changes.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies both primary fixes: the Windows file-save encoding issue and the HarfBuzz use-after-free.
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 a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

CI annotation context is incomplete: annotation collection unavailable or limited

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

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: Stirling-Tools/JPDFium/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 931f3819-d2a1-40d6-a383-2eacaf732524
📥 Commits

Reviewing files that changed from the base of the PR and between cb14e92 and 3b83e51.

📒 Files selected for processing: 4
  • CHANGELOG.md
  • jpdfium/src/test/java/stirling/software/jpdfium/SaveEncodingNativeSmokeTest.java
  • native/bridge/src/jpdfium_document.cpp
  • native/bridge/src/jpdfium_stub.cpp

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📜 Review details
⏰ Context from checks skipped due to timeout: 23
  • GitHub Check: build-natives (windows-arm64, windows-11-arm)
  • GitHub Check: build-natives (windows-x64, windows-latest)
  • GitHub Check: build-natives (linux-arm64, ubuntu-24.04-arm)
  • GitHub Check: build-natives (darwin-x64, macos-15-intel)
  • GitHub Check: CodeQL Analysis (c-cpp)
  • GitHub Check: Restricted-env compat (no execstack + hermetic bundle)
  • GitHub Check: Samples E2E Suite (All 88 Feature Samples)
  • GitHub Check: build-natives (darwin-arm64, macos-14)
  • GitHub Check: Build & Verify (Compilation) (macos-14)
  • GitHub Check: Flaky-test guard (3× rerun)
  • GitHub Check: prep-windows-icu
  • GitHub Check: Samples E2E (88 features via RunAllSamples)
  • GitHub Check: Build & Verify (Compilation) (windows-latest)
  • GitHub Check: CodeQL Analysis (java-kotlin)
  • GitHub Check: C++ - clang-tidy + cppcheck + clang-format
  • GitHub Check: JMH Benchmarks (FFM Downcall Overhead Gate)
  • GitHub Check: GraalVM Native Image Smoke & E2E Test (Linux x64)
  • GitHub Check: Java - SpotBugs + Checkstyle + PMD + Spotless
  • GitHub Check: Native bridge libFuzzer (ASan/UBSan, real PDFium)
  • GitHub Check: CodeQL (c-cpp)
  • GitHub Check: CodeQL (java-kotlin)
  • GitHub Check: Corpus (generate + native)
  • GitHub Check: CLI correctness & no-corruption tests
🧰 Additional context used
📚 Code guidelines: 1
.github/CODERABBIT_REVIEW.md — configured
📓 Path-based instructions: 4
Apply the native ownership, C ABI, C++23, engine integration, memory, and SIMD rules from .github/CODERABBIT_REVIEW.md.

⚙️ CodeRabbit configuration file

Files:

  • native/bridge/src/jpdfium_document.cpp
  • native/bridge/src/jpdfium_stub.cpp
Enforce meaningful assertions, deterministic concurrency, failure-path cleanup, and explicit native/stub requirements.

⚙️ CodeRabbit configuration file

Files:

  • jpdfium/src/test/java/stirling/software/jpdfium/SaveEncodingNativeSmokeTest.java
Apply the Java 25 and FFM rules from .github/CODERABBIT_REVIEW.md.

⚙️ CodeRabbit configuration file

Files:

  • jpdfium/src/test/java/stirling/software/jpdfium/SaveEncodingNativeSmokeTest.java
Source excerpt: Use imports rather than package-qualified type names in method bodies and signatures.

📄 CodeRabbit inference engine (.github/CODERABBIT_REVIEW.md)

Files:

  • native/bridge/src/jpdfium_document.cpp
  • native/bridge/src/jpdfium_stub.cpp
  • CHANGELOG.md
  • jpdfium/src/test/java/stirling/software/jpdfium/SaveEncodingNativeSmokeTest.java

Comment thread jpdfium/src/test/java/stirling/software/jpdfium/SaveEncodingNativeSmokeTest.java Outdated
@balazs-szucs
balazs-szucs force-pushed the fix/windows-binary-save branch from 3b83e51 to c684956 Compare October 18, 2026 16:24
@balazs-szucs
balazs-szucs force-pushed the fix/windows-binary-save branch from c684956 to 4b8cb27 Compare October 18, 2026 16:47
@balazs-szucs balazs-szucs changed the title Write Windows save staging files in binary mode Fix the Windows file save encoding and a HarfBuzz use-after-free Oct 18, 2026

@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: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: Stirling-Tools/JPDFium/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: e617220b-962a-44fa-bba9-c54c33a6b249
📥 Commits

Reviewing files that changed from the base of the PR and between 3b83e51 and debbb09.

📒 Files selected for processing: 3
  • CHANGELOG.md
  • jpdfium/src/test/java/stirling/software/jpdfium/SaveEncodingNativeSmokeTest.java
  • native/bridge/src/jpdfium_redact_pattern.cpp

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📜 Review details
⏰ Context from checks skipped due to timeout: 24
  • GitHub Check: prep-windows-icu
  • GitHub Check: CodeQL (c-cpp)
  • GitHub Check: CodeQL (java-kotlin)
  • GitHub Check: Restricted-env compat (no execstack + hermetic bundle)
  • GitHub Check: GraalVM Native Image Smoke & E2E Test (Linux x64)
  • GitHub Check: Samples E2E Suite (All 88 Feature Samples)
  • GitHub Check: Samples E2E (88 features via RunAllSamples)
  • GitHub Check: Build & Verify (Compilation) (ubuntu-latest)
  • GitHub Check: CodeQL Analysis (java-kotlin)
  • GitHub Check: build-natives (darwin-arm64, macos-14)
  • GitHub Check: build-natives (linux-arm64, ubuntu-24.04-arm)
  • GitHub Check: Build & Verify (Compilation) (windows-latest)
  • GitHub Check: JMH Benchmarks (FFM Downcall Overhead Gate)
  • GitHub Check: Build & Verify (Compilation) (macos-14)
  • GitHub Check: build-natives (darwin-x64, macos-15-intel)
  • GitHub Check: build-natives (windows-x64, windows-latest)
  • GitHub Check: CodeQL Analysis (c-cpp)
  • GitHub Check: Flaky-test guard (3× rerun)
  • GitHub Check: build-natives (windows-arm64, windows-11-arm)
  • GitHub Check: Corpus (generate + native)
  • GitHub Check: Native bridge libFuzzer (ASan/UBSan, real PDFium)
  • GitHub Check: C++ - clang-tidy + cppcheck + clang-format
  • GitHub Check: CLI correctness & no-corruption tests
  • GitHub Check: Java - SpotBugs + Checkstyle + PMD + Spotless
🧰 Additional context used
📚 Code guidelines: 1
.github/CODERABBIT_REVIEW.md — configured
📓 Path-based instructions: 4
Apply the native ownership, C ABI, C++23, engine integration, memory, and SIMD rules from .github/CODERABBIT_REVIEW.md.

⚙️ CodeRabbit configuration file

Files:

  • native/bridge/src/jpdfium_redact_pattern.cpp
Enforce meaningful assertions, deterministic concurrency, failure-path cleanup, and explicit native/stub requirements.

⚙️ CodeRabbit configuration file

Files:

  • jpdfium/src/test/java/stirling/software/jpdfium/SaveEncodingNativeSmokeTest.java
Apply the Java 25 and FFM rules from .github/CODERABBIT_REVIEW.md.

⚙️ CodeRabbit configuration file

Files:

  • jpdfium/src/test/java/stirling/software/jpdfium/SaveEncodingNativeSmokeTest.java
Source excerpt: Use imports rather than package-qualified type names in method bodies and signatures.

📄 CodeRabbit inference engine (.github/CODERABBIT_REVIEW.md)

Files:

  • CHANGELOG.md
  • jpdfium/src/test/java/stirling/software/jpdfium/SaveEncodingNativeSmokeTest.java
  • native/bridge/src/jpdfium_redact_pattern.cpp
🔇 Additional comments: 1
native/bridge/src/jpdfium_redact_pattern.cpp: 1

962-964: LGTM!

Also applies to: 966-966

Comment thread jpdfium/src/test/java/stirling/software/jpdfium/SaveEncodingNativeSmokeTest.java Outdated
Comment thread jpdfium/src/test/java/stirling/software/jpdfium/SaveEncodingNativeSmokeTest.java Outdated
@balazs-szucs

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@Frooodle
Frooodle added this pull request to the merge queue Oct 19, 2026
@balazs-szucs
balazs-szucs removed this pull request from the merge queue due to a manual request Oct 19, 2026
@balazs-szucs

Copy link
Copy Markdown
Collaborator Author

This is not synced with upstream main + I wanna port freebsd flaky fix again here.

I am testing the CI workflow on my fork. It annoys the hell out of me how the BSD infra is setup because there no obvious easy way to make the CI non-flaky. But alas, i will try to do some magic.

@balazs-szucs
balazs-szucs added this pull request to the merge queue Oct 19, 2026
Merged via the queue into Stirling-Tools:main with commit 6cdae8b Oct 19, 2026
75 checks passed
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