Skip to content

Fix leaking trait futures nondeterministically#35

Merged
skeet70 merged 43 commits intomainfrom
ci-runs-working
Apr 11, 2025
Merged

Fix leaking trait futures nondeterministically#35
skeet70 merged 43 commits intomainfrom
ci-runs-working

Conversation

@skeet70
Copy link
Copy Markdown
Member

@skeet70 skeet70 commented Apr 4, 2025

The class we were using to cleanup foreign futures on the Java side was parameterized on the future it may need to cancel when freeing. When instantiated though instances of that class weren't being pinned anywhere, so Java was nondeterministically (and almost never locally) choosing to garbage collect them. In that case Rust would call to the memory address it had for free on the Java side, with the handle it wanted freed. There would be nothing listening on the Java side though and it'd silently fail.

This refactors the object pinned into the handle map to contain both the Java completable future (childFuture) and the async job that handles a response from it (calling back to Rust with the result). Then the free impl class is able to be a static singleton with no context, and is always there when Rust calls for it.

I had to extend the immediately timer again. I'm not sure if that's because of the additional singleton that must be loaded (unlikely) or that github was randomly slower for a bit (likely). Either way it reminded me we should really look at #25 again to improve performance. JNR may be an easy enough conversion for us to use it until JDK 25 releases in September making the new FFM (Foreign Functions and Memory) API available in an LTS.

Fixes #19

@skeet70 skeet70 requested a review from a team as a code owner April 4, 2025 17:12
@skeet70 skeet70 requested review from giarc3 and removed request for a team April 4, 2025 17:12
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 4, 2025

File Coverage Lines
All files 80% 80%
src/gen_java/variant.rs 64% 64%
src/gen_java/compounds.rs 78% 78%
src/gen_java/enum_.rs 73% 73%

Minimum allowed coverage is 0%

Generated by 🐒 cobertura-action against 6916196

@skeet70 skeet70 changed the title CI run is working again, fix formatting Fix leaking trait futures nondeterministically Apr 10, 2025
@skeet70 skeet70 merged commit 743ede4 into main Apr 11, 2025
7 checks passed
@skeet70 skeet70 deleted the ci-runs-working branch April 11, 2025 16:37
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.

Fix async futures fixtures test

3 participants