cmd/compile: inconsistency with whether wrapper shows in traceback in race mode when method is tail call optimized #73915
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Uh oh!
There was an error while loading. Please reload this page.
Go version
go version go1.25-devel_dbaa2d3e65 Wed May 28 20:35:09 2025 -0700 linux/amd64
Output of
go env
in your module/workspace:What did you do?
Consider the following two examples in the next section. They are supposed to cause a race which may be detected using instrumentation with
-race
option and has a wrapper for theBase
type's methodMethod
(generated for theDerived
). The wrapper is present as an inner frame of stack trace we expect to get for the race. We prevent inlining ofMethod
into its wrapper in this example usinggo:noinline
.What did you see happen?
For the first example (where receiver is value) the wrapper is visible in the output:
Second example: if we change the
Method
to have pointer receiver (the only change compared to racewrapval.go above), the call trace with the-race
option does not include the wrapper:In the second example, the instrumentation calls to
runtime.racefuncenter
/runtime.racefuncexit
are removed by opt because there is no call in the wrapper - there is a tail call instead. Also, after the tail call there is no place to add call toracefuncexit
.What did you expect to see?
I wonder, do we expect consistency between pointer and non-pointer method wrappers in showing/not showing them in the trace with
-race
option. If they better to keep consistent, which way of handling wrappers in such trace would be preferred: (1) with wrapper's inner frames included like it works in the first example or (2) omit the inner frames from wrapper in trace, like it works in the second example and in general trace ( see #73747 ).We could get consistent (1) behavior disabling tail call when the instrumentation is enabled: in this case there would be remaining call in the wrapper which prevents optimizing away calls to
runtime.racefuncenter
/runtime.racefuncexit
. On the other hand, if we want to always omit them (2), perhaps we need to avoid inserting this part of instrumentation inssagen
for the wrappers. But if we inlined into the wrapper then such instrumentation seems still needed.The text was updated successfully, but these errors were encountered: