fix: don't set parent on xattr walk fidRefs - #106
Merged
Conversation
The txattrwalk handler created fidRefs with parent set to ref.parent but never called addChild or parent.IncRef. This caused two issues: 1. DecRef called parent.pathNode.removeChild on a ref that was never registered, triggering a spurious NOT FOUND. 2. DecRef called parent.DecRef without a matching IncRef, which could prematurely drop the parent's refcount to zero and remove other legitimately registered refs from childRefNames, leading to a panic in nameFor during clone walks. Xattr fids are ephemeral and don't represent filesystem paths, so they should not participate in path tree tracking. Setting parent to nil (the zero value, already omitted) prevents DecRef from touching the path tree or parent ref.
Signed-off-by: Chris Koch <c@chrisko.ch>
hugelgupf
force-pushed
the
fix-path-tree-panic
branch
from
May 15, 2026 22:44
dcd817f to
9330a6d
Compare
hugelgupf
approved these changes
May 15, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #106 +/- ##
==========================================
- Coverage 61.63% 61.62% -0.01%
==========================================
Files 37 37
Lines 3871 3870 -1
==========================================
- Hits 2386 2385 -1
Misses 1276 1276
Partials 209 209
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
I kept on getting "bad address" (EFAULT) errors with a dynamic 9p filesystem I am building. After (a lot of) tracing, I think I've narrowed it down to this -- but I could do with some sanity checking, especially around the xattr calls behaviour which I only discovered thanks to diod.
The txattrwalk handler created fidRefs with parent set to ref.parent but never called addChild or parent.IncRef. This caused two issues:
DecRef called parent.pathNode.removeChild on a ref that was never registered, triggering a spurious NOT FOUND.
DecRef called parent.DecRef without a matching IncRef, which could prematurely drop the parent's refcount to zero and remove other legitimately registered refs from childRefNames, leading to a panic in nameFor during clone walks.
Xattr fids are ephemeral and don't represent filesystem paths, so they should not participate in path tree tracking. Setting parent to nil (the zero value, already omitted) prevents DecRef from touching the path tree or parent ref.