Skip to content

Conversation

jungnitz
Copy link

@jungnitz jungnitz commented Aug 8, 2025

Hi, thanks for the library!

When using the Streams for text extraction, GlobalRefs are dropped after the thread is already detached from the VM. This leads to a warning from jni crate:

Dropping a GlobalRef in a detached thread. Fix your code if this message appears frequently (see the GlobalRef docs).

I fixed this by including the AttachGuard in the JReaderInputStream struct, so that the thread is detached only after all GlobalRefs in it are dropped.

(also, the tagged v0.3.0 commit is not part of any branch in this repository and main is outdated)

@jungnitz
Copy link
Author

Ah, I see. This seems to be incompatible with the Python bindings, because pyobjects have to be Send and that is obviously not implemented for AttachGuard.
I have put the changes behind a feature flag so that it does no longer break the Python builds. Depending on whether this change would be included in a minor or patch release, one could also think about making it a default feature and disabling it for the python bindings, which I personally would prefer.

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