Skip to content

time,runtime: too many concurrent timer firings for short, fast-resetting time.Timer #69969

@mknyszek

Description

@mknyszek

This issue is the same as #69880 but for regular a time.Timer. The difference between a regular time.Timer and a time.Ticker is that it is much harder to reproduce the problem for a time.Timer. The timer must be getting reset at just the right time, with a very low duration, so that it fires again. And this needs to happen 8 times.

The probability of this is very low, but it is possible to write code that causes this (though it's unclear if the code is useful). Slightly more concerning, however, is that there is an incredibly low chance of this just happening due to sheer luck.

I was basically only able to create a test for this that involves a timer that basically fires immediately (nanoseconds-long timer). Still, it is one additional possible problem.

Given that #69880 is fixed, fixing this isn't quite so important, but it turns out we can do so easily, to just close the door on this entirely.

It turns out that due to size class bumping from allocation headers, it costs us no extra memory to represent isSending as an atomic.Int32 instead, so we can make the maximal number of concurrent timer firings something so absurdly large (2^31-1) that it will actually never happen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixPendingIssues that have a fix which has not yet been reviewed or submitted.NeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions