Skip to content

fix: don't set parent on xattr walk fidRefs - #106

Merged
hugelgupf merged 2 commits into
hugelgupf:mainfrom
dotwaffle:fix-path-tree-panic
May 15, 2026
Merged

fix: don't set parent on xattr walk fidRefs#106
hugelgupf merged 2 commits into
hugelgupf:mainfrom
dotwaffle:fix-path-tree-panic

Conversation

@dotwaffle

Copy link
Copy Markdown
Contributor

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:

  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.

dotwaffle and others added 2 commits May 15, 2026 15:44
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
hugelgupf force-pushed the fix-path-tree-panic branch from dcd817f to 9330a6d Compare May 15, 2026 22:44
@codecov

codecov Bot commented May 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.62%. Comparing base (0601c93) to head (9330a6d).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
p9/handlers.go 33.33% 2 Missing ⚠️
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              
Flag Coverage Δ
macos-latest-unit 46.38% <0.00%> (+0.01%) ⬆️
ubuntu-latest-unit 45.49% <0.00%> (+0.01%) ⬆️
ubuntu-vm-amd64 61.77% <50.00%> (-0.02%) ⬇️
ubuntu-vm-arm 60.24% <50.00%> (-0.02%) ⬇️
ubuntu-vm-arm64 60.24% <50.00%> (-0.02%) ⬇️
windows-latest-unit 46.50% <0.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hugelgupf
hugelgupf merged commit c6d1f8c into hugelgupf:main May 15, 2026
36 of 38 checks passed
@dotwaffle
dotwaffle deleted the fix-path-tree-panic branch May 16, 2026 00:59
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.

2 participants