Repository navigation
fix(hdfs_3_3): detach only threads attached by libhdfs - #47
Merged
Xuanwo merged 1 commit intoSep 22, 2026
Merged
Conversation
peterxcli
marked this pull request as ready for review
July 27, 2026 06:20
Contributor
Author
|
@Xuanwo any chance you could take a look at this? I'd really appreciate any insight you could provide! This would help me fix a lot of flaky tests in DataFusion Comet: apache/datafusion-comet#5036 (comment) |
Contributor
Author
|
@Xuanwo thanks! |
peterxcli
added a commit
to peterxcli/datafusion-comet
that referenced
this pull request
Sep 26, 2026
hdfs-sys 0.3.1 includes the libhdfs thread destructor fix (Xuanwo/hdfs-sys#47), so the workspace [patch.crates-io] pin is no longer needed.
comphead
pushed a commit
to comphead/arrow-datafusion-comet
that referenced
this pull request
Sep 29, 2026
* fix: pin patched hdfs-sys for safe thread cleanup * deps: use hdfs-sys 0.3.1 release instead of git patch hdfs-sys 0.3.1 includes the libhdfs thread destructor fix (Xuanwo/hdfs-sys#47), so the workspace [patch.crates-io] pin is no longer needed. --------- Co-authored-by: Andy Grove <[email protected]>
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
GetEnvto distinguish JVM-owned threads from detached native threadsGetJavaVMandDetachCurrentThreadonly for libhdfs-owned attachmentsMotivation
The POSIX
hdfsThreadDestructorunconditionally dereferences the cachedJNIEnvand detaches the thread. For a thread already attached by the JVM, that environment can be freed before the native TLS destructor runs, causing a use-after-free and a jump through an invalid JNI function table.This matches HDFS-16021 and was reproduced downstream in apache/datafusion-comet#5023.
This PR is intentionally scoped to the
hdfs_3_3POSIX source selected by the affected downstream. Older vendored Hadoop snapshots use different TLS layouts and need separate adaptations.Testing
cargo test --features hdfs_3_3,vendoredon macOS ARM64 with JDK 17: 13 passedcargo fmt --all -- --checkParquetReadFromFakeHadoopFsSuite