Commit 5e673d4
authored
fix: Prevent panic on concurrent sharing revocation (#4617)
A nil pointer dereference panic occurred at model/sharing/oauth.go:652
when multiple goroutines concurrently revoked the same sharing members.
```
2025-11-27T10:35:49.710Z time="2025-11-27T10:35:49.683Z" level=error msg="[panic] runtime error: invalid memory address or nil pointer dereference: goroutine 8354870 [running]:
runtime/debug.Stack()
/home/jenkins/workspace/cozy-stack/gozy-bookworm-int-01-build/build/go/src/runtime/debug/stack.go:24 +0x5e
github.com/cozy/cozy-stack/model/sharing.(*Sharing).Replicate.func1.1()
/home/jenkins/workspace/cozy-stack/gozy-bookworm-int-01-build/build/cozy-stack/src/github.com/cozy/cozy-stack/model/sharing/replicator.go:74 +0x4f
panic({0x161eda0?, 0x299b370?})
/home/jenkins/workspace/cozy-stack/gozy-bookworm-int-01-build/build/go/src/runtime/panic.go:770 +0x132
github.com/cozy/cozy-stack/model/sharing.RefreshToken(0xc0104578c8?, {0x1d7f680?, 0xc0118911d0?}, 0xc010a8a000?, 0xc010a980e8?, 0xc000277860, 0xc0000574c0, {0x0, 0x0, 0x0})
/home/jenkins/workspace/cozy-stack/gozy-bookworm-int-01-build/build/cozy-stack/src/github.com/cozy/cozy-stack/model/sharing/oauth.go:652 +0x115
github.com/cozy/cozy-stack/model/sharing.(*Sharing).NotifyMemberRevocation(0xc010a8a000, 0xc0104578c8, 0xc010a980e8, 0xc000277860)
/home/jenkins/workspace/cozy-stack/gozy-bookworm-int-01-build/build/cozy-stack/src/github.com/cozy/cozy-stack/model/sharing/member.go:1071 +0x3d3
github.com/cozy/cozy-stack/model/sharing.(*Sharing).RevokeMember(0xc010a8a000, 0xc0104578c8, 0x2)
/home/jenkins/workspace/cozy-stack/gozy-bookworm-int-01-build/build/cozy-stack/src/github.com/cozy/cozy-stack/model/sharing/member.go:965 +0xd0
github.com/cozy/cozy-stack/model/sharing.(*Sharing).Revoke(0xc010a8a000, 0xc0104578c8)
/home/jenkins/workspace/cozy-stack/gozy-bookworm-int-01-build/build/cozy-stack/src/github.com/cozy/cozy-stack/model/sharing/sharing.go:457 +0xb1
github.com/cozy/cozy-stack/model/sharing.(*Sharing).ReplicateTo(0xc010a8a000, 0xc0104578c8, 0xc010a988c8, 0x0)
/home/jenkins/workspace/cozy-stack/gozy-bookworm-int-01-build/build/cozy-stack/src/github.com/cozy/cozy-stack/model/sharing/replicator.go:193 +0x565
github.com/cozy/cozy-stack/model/sharing.(*Sharing).Replicate.func [TRUNCATED]" domain=cantoine2.mytoutatice.cloud
```
`Replicate()` spawns parallel goroutines for each member and each
goroutine that encountered `errRevokeSharing` independently called
`s.Revoke()`3 files changed
Lines changed: 18 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
958 | 958 | | |
959 | 959 | | |
960 | 960 | | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
961 | 967 | | |
962 | 968 | | |
963 | 969 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
649 | 649 | | |
650 | 650 | | |
651 | 651 | | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
652 | 656 | | |
653 | 657 | | |
654 | 658 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
93 | 99 | | |
94 | 100 | | |
95 | 101 | | |
| |||
188 | 194 | | |
189 | 195 | | |
190 | 196 | | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | 197 | | |
199 | 198 | | |
200 | 199 | | |
| |||
0 commit comments