Skip to content

Commit

Permalink
Prevent nil pointer dereference
Browse files Browse the repository at this point in the history
poisonDeadlock
  • Loading branch information
tralafiti committed Jul 5, 2024
1 parent b0e8700 commit e1077eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions actor/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ func TestPoisonWaitGroup(t *testing.T) {
case <-time.After(20 * time.Millisecond):
t.Error("poison waitGroup deadlocked")
}
// ... or panic
e.Poison(nil).Wait()
}

func TestPoison(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions actor/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ func (r *Registry) Remove(pid *PID) {
// If it doesn't exist, nil is returned so the caller must check for that
// and direct the message to the deadletter processer instead.
func (r *Registry) get(pid *PID) Processer {
if pid == nil {
return nil
}
r.mu.RLock()
defer r.mu.RUnlock()
if proc, ok := r.lookup[pid.ID]; ok {
Expand Down

0 comments on commit e1077eb

Please sign in to comment.