Fix native library loading failure due to buffer comparison bug - #318
Merged
Conversation
…son (#317) Compare only the bytes actually read from each stream instead of the entire 8192-byte buffer in contentsEquals(). When the final chunk is smaller than the buffer, stale bytes from the previous iteration could cause a false mismatch, preventing the native library from loading. Uses a byte-by-byte loop instead of Arrays.equals() to maintain JDK 8 compatibility. Fixes #317 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
sarutak
pushed a commit
to apache/spark
that referenced
this pull request
Apr 18, 2026
### What changes were proposed in this pull request? This PR upgrades `Maven` to 3.9.15. ### Why are the changes needed? To use the latest Maven version. - https://maven.apache.org/docs/3.9.15/release-notes.html - apache/maven#11876 - codehaus-plexus/plexus-utils#304 - apache/maven#11865 - fusesource/jansi#318 - fusesource/jansi#317 - https://github.com/apache/maven/releases/tag/maven-3.9.15 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Pass the CIs and check the log. - https://github.com/dongjoon-hyun/spark/actions/runs/24586452868/job/71897297495 ``` Using `mvn` from path: /home/runner/work/spark/spark/build/apache-maven-3.9.15/bin/mvn ``` ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (claude-opus-4-7) Closes #55398 from dongjoon-hyun/SPARK-56530. Authored-by: Dongjoon Hyun <dongjoon@apache.org> Signed-off-by: Kousuke Saruta <sarutak@apache.org>
breskeby
added a commit
to elastic/elasticsearch
that referenced
this pull request
Aug 4, 2026
JANSI 2.4.0's JansiLoader.extractAndLoadLibraryFile verifies the native library it extracts by comparing the jar resource stream against the extracted file using Arrays.equals on reused 8192-byte buffers without limiting the comparison to the bytes actually read. On Linux systems where the JDK dynamically links the system zlib (the openjdk.org GA builds bundled with Elasticsearch for new major JDK versions), this latent bug is triggered by zlib-ng: EL10-family distros (RHEL 10, AlmaLinux 10, Rocky Linux 10, Oracle Linux 10) ship zlib-ng-compat as libz.so.1, whose SIMD-optimized inflate writes scratch bytes beyond the reported read count. The stale byte in the reused buffer then falsely signals corruption, JANSI throws a RuntimeException that is silently swallowed (jansi.graceful=true), CLibrary.LOADED stays false, and AnsiConsole reports AnsiType.Unsupported with terminal width 0. AnsiConsoleLoader consequently returns null instead of a valid console, and InitialNodeSecurityAutoConfiguration skips credential generation at first startup. JANSI 2.4.3 fixes the comparison to only consider bytes actually read (fusesource/jansi#318). Closes #154510
breskeby
added a commit
to elastic/elasticsearch
that referenced
this pull request
Aug 4, 2026
…ux (#155853) JANSI 2.4.0's JansiLoader.extractAndLoadLibraryFile verifies the native library it extracts by comparing the jar resource stream against the extracted file using Arrays.equals on reused 8192-byte buffers without limiting the comparison to the bytes actually read. On Linux systems where the JDK dynamically links the system zlib (the openjdk.org GA builds bundled with Elasticsearch for new major JDK versions), this latent bug is triggered by zlib-ng: EL10-family distros (RHEL 10, AlmaLinux 10, Rocky Linux 10, Oracle Linux 10) ship zlib-ng-compat as libz.so.1, whose SIMD-optimized inflate writes scratch bytes beyond the reported read count. The stale byte in the reused buffer then falsely signals corruption, JANSI throws a RuntimeException that is silently swallowed (jansi.graceful=true), CLibrary.LOADED stays false, and AnsiConsole reports AnsiType.Unsupported with terminal width 0. AnsiConsoleLoader consequently returns null instead of a valid console, and InitialNodeSecurityAutoConfiguration skips credential generation at first startup. JANSI 2.4.3 fixes the comparison to only consider bytes actually read (fusesource/jansi#318). Closes #154510
breskeby
added a commit
to elastic/elasticsearch
that referenced
this pull request
Aug 4, 2026
…ux (#155853) (#155893) JANSI 2.4.0's JansiLoader.extractAndLoadLibraryFile verifies the native library it extracts by comparing the jar resource stream against the extracted file using Arrays.equals on reused 8192-byte buffers without limiting the comparison to the bytes actually read. On Linux systems where the JDK dynamically links the system zlib (the openjdk.org GA builds bundled with Elasticsearch for new major JDK versions), this latent bug is triggered by zlib-ng: EL10-family distros (RHEL 10, AlmaLinux 10, Rocky Linux 10, Oracle Linux 10) ship zlib-ng-compat as libz.so.1, whose SIMD-optimized inflate writes scratch bytes beyond the reported read count. The stale byte in the reused buffer then falsely signals corruption, JANSI throws a RuntimeException that is silently swallowed (jansi.graceful=true), CLibrary.LOADED stays false, and AnsiConsole reports AnsiType.Unsupported with terminal width 0. AnsiConsoleLoader consequently returns null instead of a valid console, and InitialNodeSecurityAutoConfiguration skips credential generation at first startup. JANSI 2.4.3 fixes the comparison to only consider bytes actually read (fusesource/jansi#318). Closes #154510 (cherry picked from commit 8a98623) # Conflicts: # gradle/verification-metadata.xml # muted-tests.yml
breskeby
added a commit
to elastic/elasticsearch
that referenced
this pull request
Aug 4, 2026
…ux (#155853) (#155882) JANSI 2.4.0's JansiLoader.extractAndLoadLibraryFile verifies the native library it extracts by comparing the jar resource stream against the extracted file using Arrays.equals on reused 8192-byte buffers without limiting the comparison to the bytes actually read. On Linux systems where the JDK dynamically links the system zlib (the openjdk.org GA builds bundled with Elasticsearch for new major JDK versions), this latent bug is triggered by zlib-ng: EL10-family distros (RHEL 10, AlmaLinux 10, Rocky Linux 10, Oracle Linux 10) ship zlib-ng-compat as libz.so.1, whose SIMD-optimized inflate writes scratch bytes beyond the reported read count. The stale byte in the reused buffer then falsely signals corruption, JANSI throws a RuntimeException that is silently swallowed (jansi.graceful=true), CLibrary.LOADED stays false, and AnsiConsole reports AnsiType.Unsupported with terminal width 0. AnsiConsoleLoader consequently returns null instead of a valid console, and InitialNodeSecurityAutoConfiguration skips credential generation at first startup. JANSI 2.4.3 fixes the comparison to only consider bytes actually read (fusesource/jansi#318). Closes #154510 (cherry picked from commit 8a98623) # Conflicts: # muted-tests.yml
breskeby
added a commit
to elastic/elasticsearch
that referenced
this pull request
Aug 4, 2026
…ux (#155853) (#155884) JANSI 2.4.0's JansiLoader.extractAndLoadLibraryFile verifies the native library it extracts by comparing the jar resource stream against the extracted file using Arrays.equals on reused 8192-byte buffers without limiting the comparison to the bytes actually read. On Linux systems where the JDK dynamically links the system zlib (the openjdk.org GA builds bundled with Elasticsearch for new major JDK versions), this latent bug is triggered by zlib-ng: EL10-family distros (RHEL 10, AlmaLinux 10, Rocky Linux 10, Oracle Linux 10) ship zlib-ng-compat as libz.so.1, whose SIMD-optimized inflate writes scratch bytes beyond the reported read count. The stale byte in the reused buffer then falsely signals corruption, JANSI throws a RuntimeException that is silently swallowed (jansi.graceful=true), CLibrary.LOADED stays false, and AnsiConsole reports AnsiType.Unsupported with terminal width 0. AnsiConsoleLoader consequently returns null instead of a valid console, and InitialNodeSecurityAutoConfiguration skips credential generation at first startup. JANSI 2.4.3 fixes the comparison to only consider bytes actually read (fusesource/jansi#318). Closes #154510 (cherry picked from commit 8a98623) # Conflicts: # gradle/verification-metadata.xml # muted-tests.yml
breskeby
added a commit
to elastic/elasticsearch
that referenced
this pull request
Aug 4, 2026
…ux (#155853) (#155886) JANSI 2.4.0's JansiLoader.extractAndLoadLibraryFile verifies the native library it extracts by comparing the jar resource stream against the extracted file using Arrays.equals on reused 8192-byte buffers without limiting the comparison to the bytes actually read. On Linux systems where the JDK dynamically links the system zlib (the openjdk.org GA builds bundled with Elasticsearch for new major JDK versions), this latent bug is triggered by zlib-ng: EL10-family distros (RHEL 10, AlmaLinux 10, Rocky Linux 10, Oracle Linux 10) ship zlib-ng-compat as libz.so.1, whose SIMD-optimized inflate writes scratch bytes beyond the reported read count. The stale byte in the reused buffer then falsely signals corruption, JANSI throws a RuntimeException that is silently swallowed (jansi.graceful=true), CLibrary.LOADED stays false, and AnsiConsole reports AnsiType.Unsupported with terminal width 0. AnsiConsoleLoader consequently returns null instead of a valid console, and InitialNodeSecurityAutoConfiguration skips credential generation at first startup. JANSI 2.4.3 fixes the comparison to only consider bytes actually read (fusesource/jansi#318). Closes #154510 (cherry picked from commit 8a98623) # Conflicts: # gradle/verification-metadata.xml # muted-tests.yml
tveasey
pushed a commit
to tveasey/elasticsearch
that referenced
this pull request
Aug 6, 2026
…ux (elastic#155853) JANSI 2.4.0's JansiLoader.extractAndLoadLibraryFile verifies the native library it extracts by comparing the jar resource stream against the extracted file using Arrays.equals on reused 8192-byte buffers without limiting the comparison to the bytes actually read. On Linux systems where the JDK dynamically links the system zlib (the openjdk.org GA builds bundled with Elasticsearch for new major JDK versions), this latent bug is triggered by zlib-ng: EL10-family distros (RHEL 10, AlmaLinux 10, Rocky Linux 10, Oracle Linux 10) ship zlib-ng-compat as libz.so.1, whose SIMD-optimized inflate writes scratch bytes beyond the reported read count. The stale byte in the reused buffer then falsely signals corruption, JANSI throws a RuntimeException that is silently swallowed (jansi.graceful=true), CLibrary.LOADED stays false, and AnsiConsole reports AnsiType.Unsupported with terminal width 0. AnsiConsoleLoader consequently returns null instead of a valid console, and InitialNodeSecurityAutoConfiguration skips credential generation at first startup. JANSI 2.4.3 fixes the comparison to only consider bytes actually read (fusesource/jansi#318). Closes elastic#154510
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
contentsEquals()inJansiLoaderto compare only the bytes actually read from each stream, instead of comparing the entire 8192-byte buffer viaArrays.equals()Arrays.equals(byte[], int, int, byte[], int, int)overloadFixes #317
Test plan
🤖 Generated with Claude Code
Claude Code on behalf of Guillaume Nodet