Repository navigation
Fix use-after-free - #178
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Shutdown resource ordering jfuse-api/src/main/java/org/cryptomator/jfuse/api/FuseMount.java, jfuse-win/src/main/java/org/cryptomator/jfuse/win/FuseMountImpl.java, CHANGELOG.md |
The API documentation assigns release of run-loop resources to destroy(). The Windows implementation calls fuse3_exit() in unmount() and calls fuse3_unmount() before fuse3_destroy() in destroy(). The changelog records the Windows unmount crash fix. |
Repeated mount and close test jfuse-tests/src/test/java/org/cryptomator/jfuse/tests/UnmountStressIT.java |
A Windows-only test runs 30 mount and close cycles. Each cycle writes and verifies a file, checks a directory listing, deletes the file, and closes the filesystem with a timeout. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Merge Risk: 
Low · up to 930d3
-
The change fixes the Windows crash that occurred when unmounting. In the rare case where closing is interrupted or the loop takes over 10 seconds to stop, the native WinFsp cleanup is now skipped and its memory can leak. This is a narrow edge case, so the change is mergeable, though the maintainers should be aware of it.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 3 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
There was a problem hiding this comment.
🔵 Needs a closer look
Cross-thread native WinFsp lifetime and shutdown changes require Windows stress-test validation against WinFsp 2025 and CI-pinned 2.0.23075, which this review environment cannot provide.
No open issues 🎉
What changed in this PR
Fixes the Windows unmount use-after-free described in #176 by deferring WinFsp resource cleanup until after the run loop exits.
Changes:
- Moves
fuse3_unmount()fromunmount()todestroy(), leavingunmount()to signal loop exit. - Adds a Windows regression test covering 30 mount, file-operation, and close cycles.
- Documents the lifecycle requirement and records the crash fix in the changelog.
| File | Description |
|---|---|
jfuse-win/src/main/java/org/cryptomator/jfuse/win/FuseMountImpl.java |
Defers native resource cleanup to destroy(). |
jfuse-tests/src/test/java/org/cryptomator/jfuse/tests/UnmountStressIT.java |
Adds repeated Windows mount/unmount regression coverage. |
jfuse-api/src/main/java/org/cryptomator/jfuse/api/FuseMount.java |
Clarifies that unmount must preserve resources still used by the loop. |
CHANGELOG.md |
Records the Windows unmount crash fix. |
Review effort: Balanced
|
Windows succeeds, linux fails due to outdated workflow script |
This PR fixes a use-after-free bug when unmounting a filesyste on Windows.
Fixes #176.
Winfsp shows the peculiarity that
fuse3_unmount()does not unmount, it freesstruct fuse (fsp_fuse3_unmount() -> fsp_fuse_destroy()), which the run loop still dereferences while it winds down. The volume is detached by the run loop itself, in fsp_fuse_loop_stop() -> FspFileSystemDelete().The fix reproduces fsp_fuse3_main_real's ordering exactly, and fsp_fuse_loop_internal's if (!f->exited) guard (fuse_loop.c:319) covers the case where fuse3_exit lands before the loop starts waiting.
Summary by CodeRabbit