Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime/race: incorrect line number in race report #8053

glycerine opened this issue May 21, 2014 · 6 comments

runtime/race: incorrect line number in race report #8053

glycerine opened this issue May 21, 2014 · 6 comments


Copy link

go version go1.2.1 linux/amd64

The race detector (go test -v -race) reports line numbers that are off-by-one in at
least one instance. The race below is on err, not on w, but the race is reported at the
line (***).

// begin snippet
nwork := 10
wks := make([]<-chan bool, nwork) // a slice to store workers in.
for i := 0; i < nwork; i++ {
    w := HelperNewWorkerMonitored(cfg) // returns a new Worker every time
    afterSend, afterReply := w.NS.MonitorSend, w.NR.MonitorRecv
    wks[i] = afterReply
    go func(w *Worker) {
        _, err = w.DoOneJob()  // the race is on err here
        w.Destroy()   // but go test -race  reports race on this line (***)
Copy link

rsc commented May 21, 2014

Comment 1:

It would help to have a self-contained example instead of just a program fragment.

Status changed to WaitingForReply.

Copy link

rsc commented May 21, 2014

Comment 2:

Labels changed: added release-go1.4.

Copy link

Comment 3:

Sorry I don't have time to boil this down to a smaller example, but here is a complete
program that reproduces the bug in go1.3beta2 on linux x86_64:
this isn't the tip, because I don't want to leave the race in the code, but if you check
out that commit it will reproduce.
go test -v -race
to see the race report on line immo_test.go:42, when the bug is on immo_test.g:41.

Copy link

dvyukov commented May 26, 2014

Comment 4:

Labels changed: added repo-main, racedetector.

Owner changed to @dvyukov.

Status changed to Accepted.

Copy link

rsc commented Sep 16, 2014

Comment 5:

Dmitriy, will you have time to look into this for Go 1.4?

Copy link

dvyukov commented Sep 16, 2014

Comment 7:

I took a quick look, it will require updating all syso files which is painful and risky
at this stage. I should have been bundled this fix this something else, but I forget
about it.
Let's move this to 1.5, it does not seem to be super critical.

Labels changed: added release-go1.5, removed release-go1.4.

@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014
dvyukov added a commit that referenced this issue Feb 20, 2015
In most cases we pass return PC to race detector,
and race runtime subtracts one from them.
However, in manual instrumentation in runtime
we pass function start PC to race runtime.
Race runtime can't distinguish these cases
and so it does not subtract one from top PC.
This leads to bogus line numbers in some cases.
Make it consistent and always pass what looks
like a return PC, so that race runtime can
subtract one and still get PC in the same function.

Also delete two unused functions.

Update #8053

Change-Id: I4242dec5e055e460c9a8990eaca1d085ae240ed2
Reviewed-by: Ian Lance Taylor <>
@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

5 participants