Crash when reaping for the first time
cwimberger opened this issue · comments
I think the crash occurs when reaping for the first time.
Stack trace:
goroutine 8 [running]:
github.com/jaredfolkins/badactor.(*Director).maintenance(0xc4200fcab0, 0xc42017a720, 0xc)
/Users/chris/dev/go-workspace/src/github.com/jaredfolkins/badactor/director.go:181 +0x72
github.com/jaredfolkins/badactor.(*Director).lMaintenance(0xc4200fcab0)
/Users/chris/dev/go-workspace/src/github.com/jaredfolkins/badactor/director.go:38 +0xad
github.com/jaredfolkins/badactor.(*Studio).StartReaper.func1(0xc42001c380, 0xc4200e0e70)
/Users/chris/dev/go-workspace/src/github.com/jaredfolkins/badactor/studio.go:118 +0x132
created by github.com/jaredfolkins/badactor.(*Studio).StartReaper
/Users/chris/dev/go-workspace/src/github.com/jaredfolkins/badactor/studio.go:127 +0x57
Configuration:
st := badactor.NewStudio(256)
ru := &badactor.Rule{
Name: "RequestLimit",
Message: "Too many requests",
StrikeLimit: rpts,
ExpireBase: time.Second * 10,
Sentence: time.Minute * 5,
}
st.AddRule(ru)
err := st.CreateDirectors(256)
if err != nil {
fmt.Print(err)
}
st.StartReaper(time.Minute * time.Duration(60))
I can recreate this. I'll dig in a bit and post what I find.
Give this a shot.
There was a rare occurrence where a actor would be removed by one go-routine right as a lookup for said actor was taking place. The logic in that line was erroneous causing a panic.
it works now as expected. thanks!