Skip to content

fix: [stable-8.0.10][OCISDEV-1675] fix a nil pointer panic in the sharecache Remove - #814

Merged
2403905 merged 2 commits into
stable-8.0.10-fixfrom
fix/stable-8.0.10-OCISDEV-1675
Nov 13, 2026
Merged

2403905 merged 2 commits into
stable-8.0.10-fixfrom
fix/stable-8.0.10-OCISDEV-1675

Conversation

@2403905

@2403905 2403905 commented Nov 13, 2026 •

Copy link
Copy Markdown

Description

sharecache.Cache.Remove in pkg/share/manager/jsoncs3/sharecache/sharecache.go reads us.UserShares[ssid].IDs with no nil check. When the user has no entry for the space of the share, the entry is nil and Remove panics. A share ID without a : delimiter causes the same panic, because its space key is ":".

The panic occurs in an errgroup goroutine in pkg/share/manager/jsoncs3/jsoncs3.go (removeShare). Thus the panic stops the process. All removal paths are affected, for example Unshare and the cleanup of orphaned shares.

Fix

  • Remove skips the delete when the space entry is nil.
  • Remove still calls Persist. Persist sends the etag of the in-memory cache. When the cache is stale, the upload gets a conflict. Then RetryPersist syncs again and retries the delete. Thus a share that another node added is removed correctly.

Related fixes in pkg/share/manager/jsoncs3/providercache/providercache.go

  • PurgeSpace stored &Shares{} with a nil Shares map. A later Add to the same space panicked with "assignment to entry in nil map". PurgeSpace now stores an empty map.
  • Remove discarded the ok value of spaces.Spaces.Load and checked the ok value of Providers.Load again. Thus the guard never fired. Remove now checks the correct value. No public API path makes the space absent at this point, so this change has no test. It makes the guard work as intended.

This is a minimal fix for the stable-8.0.10-fix hotfix branch. The larger rework for stable-8.0 is in #813.

Tests

pkg/share/manager/jsoncs3/sharecache/sharecache_test.go has 3 new tests:

  1. Add a share in space-a, then Remove a share in space-b.
  2. Remove a share ID with no delimiter.
  3. Another cache instance adds a share in space-b. The local cache, which does not know space-b, removes it. The test checks that the remote file does not contain the share after this.

pkg/share/manager/jsoncs3/providercache/providercache_test.go has 1 new test: PurgeSpace, then Add to the same space.

Without the fix, all 4 tests panic. With the fix, all pkg/share/manager/jsoncs3/... packages pass with -race.

Note

The fix for the panic when a grpc server stops before it serves was pushed to this branch after the merge. It is not part of this pull request. It is in #815.

Related

  • Jira: OCISDEV-1675

🤖 Generated with Claude Code

…recache Remove

sharecache.Cache.Remove read us.UserShares[ssid].IDs with no nil check.
When the user had no entry for the space of the share, Remove panicked.
A share ID without a delimiter caused the same panic. The panic occurred
in an errgroup goroutine and stopped the process.

Remove now skips the delete when the space entry is absent. It still
persists the cache, so a stale cache gets an etag conflict, a resync
and a retry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kw-security

kw-security commented Nov 13, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

PurgeSpace stored &Shares{} with a nil Shares map. A later Add to the
same space panicked with "assignment to entry in nil map". PurgeSpace
now stores an empty map.

Remove discarded the ok value of spaces.Spaces.Load and checked the ok
value of Providers.Load again. Remove now checks the correct value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2403905 added a commit to owncloud/ocis that referenced this pull request Nov 13, 2026
… providercache

Bump reva to the head of owncloud/reva#814. The new reva commit fixes
a nil map in providercache.Cache.PurgeSpace and a wrong ok check in
providercache.Cache.Remove.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@2403905
2403905 requested a review from a team November 13, 2026 12:17
@2403905
2403905 merged commit d747301 into stable-8.0.10-fix Nov 13, 2026
16 checks passed
@2403905
2403905 deleted the fix/stable-8.0.10-OCISDEV-1675 branch November 13, 2026 12:24
2403905 added a commit to owncloud/ocis that referenced this pull request Nov 13, 2026
…s before it serves

Bump reva to the head of owncloud/reva#814. The new reva commit lets
Stop and GracefulStop of pkg/rgrpc work before the grpc server exists.
Before, a SIGTERM during a slow service start crashed the sharing
service with a nil pointer panic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2403905 added a commit to owncloud/ocis that referenced this pull request Nov 13, 2026
…ncloud/reva#814

owncloud/reva#814 is merged as d74730112. Point reva to that commit.
The merge does not contain the rgrpc stop-before-start fix. That fix
is in owncloud/reva#815. Thus this commit also removes the vendored
rgrpc change and its changelog entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

4 participants