[Go 1.25.3, macOS+Linux]
Found while debugging a production memory ~leak....
https://go.dev/play/p/dQaXA0miYoX
If you make a time.AfterFunc and Stop it, it doesn't zero out its runtime.timer.arg any interface value because you might Reset it later. But if it's Stopped and the P-heaped timer entry is zombied and the *time.Timer is no longer GC-reachable, that zombied heap entry still has that non-zero arg interface until the timer fires. (or until it becomes the min/max in the heap and cleaned)
In the repro above, it puts it in the middle of the heap, so it's not cleaned.
Can we make runtime.newTimer use AddCleanup or something (on the timeTimer wrapper around the runtime.timer) to zero out the arg field for stopped zombie timers?
[Go 1.25.3, macOS+Linux]
Found while debugging a production memory ~leak....
https://go.dev/play/p/dQaXA0miYoX
If you make a
time.AfterFuncandStopit, it doesn't zero out itsruntime.timer.arg anyinterface value because you mightResetit later. But if it's Stopped and the P-heaped timer entry is zombied and the*time.Timeris no longer GC-reachable, that zombied heap entry still has that non-zero arg interface until the timer fires. (or until it becomes the min/max in the heap and cleaned)In the repro above, it puts it in the middle of the heap, so it's not cleaned.
Can we make
runtime.newTimeruseAddCleanupor something (on thetimeTimerwrapper around theruntime.timer) to zero out theargfield for stopped zombie timers?