runtime: NumCgoCall only counts calls from threads that are still alive #46789
Labels
FrozenDueToAge
help wanted
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, this is present in the most recent stable release (go1.16.5) and in the most recent development commit (go1.17-a294e4e798, after go1.17beta1).
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I forced the runtime to create a thread, did a cgo call on that thread, and then terminated the thread. I asked the runtime for a count of "the number of cgo calls made by the current process" via runtime.NumCgoCall before making the cgo call, after making the cgo call but before triggering the runtime to destroy the thread, and again after I expected the the thread to have exited.
What did you expect to see?
I expected the result of runtime.NumCgoCall to increase by 1 for each cgo call in my program, and to never decrease.
What did you see instead?
The result of runtime.NumCgoCall only reflects calls made by threads that are still alive, so decreases when threads that have made cgo calls exit.
The text was updated successfully, but these errors were encountered: