Merge pull request #3053 from chengzhichao-xydt/codex/store-lock-type-assert

fix(evolution): add ok check for LoadOrStore type assertion in lockStoreFile
This commit is contained in:
Mauro 2026-06-23 00:04:42 +02:00 committed by GitHub
commit a75b3d15bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -558,11 +558,21 @@ func isInvalidJSON(err error) bool {
} }
func lockStoreFile(path string) func() { func lockStoreFile(path string) func() {
for {
actual, _ := storeFileLocks.LoadOrStore(path, &sync.Mutex{}) actual, _ := storeFileLocks.LoadOrStore(path, &sync.Mutex{})
mu := actual.(*sync.Mutex) mu, ok := actual.(*sync.Mutex)
if !ok || mu == nil {
// Corrupted entry (wrong type or nil *sync.Mutex).
// Atomically swap in a fresh mutex via CompareAndSwap.
// If CAS fails, another goroutine already replaced it —
// just retry the loop to pick up the valid entry.
storeFileLocks.CompareAndSwap(path, actual, &sync.Mutex{})
continue
}
mu.Lock() mu.Lock()
return mu.Unlock return mu.Unlock
} }
}
func (s *Store) profilePath(workspaceID, skillName string) (string, error) { func (s *Store) profilePath(workspaceID, skillName string) (string, error) {
if err := skills.ValidateSkillName(skillName); err != nil { if err := skills.ValidateSkillName(skillName); err != nil {