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

Running tests with -trace is failing for new versions of go #66

Closed
kapillamba4 opened this issue Sep 18, 2021 · 2 comments · Fixed by #68
Closed

Running tests with -trace is failing for new versions of go #66

kapillamba4 opened this issue Sep 18, 2021 · 2 comments · Fixed by #68

Comments

@kapillamba4
Copy link

Problem:
Using goleak with trace flag in earlier versions of go (go1.13.10) is working fine due to fixed issue #39.

But in recent version of go (go1.17.1) testing simple programs with trace flag is failing again. I think the stack trace has now hidden the call to runtime.goparkunlock

func Test(t *testing.T) {
	defer goleak.VerifyNone(t)
}
make test:
        [Goroutine 18 in state trace reader (blocked), with runtime.ReadTrace on top of the stack:
        goroutine 18 [trace reader (blocked)]:
        runtime.ReadTrace()
        	/usr/local/go/src/runtime/trace.go:412 +0xd2
        runtime/trace.Start.func1()
        	/usr/local/go/src/runtime/trace/trace.go:129 +0x47
        created by runtime/trace.Start
        	/usr/local/go/src/runtime/trace/trace.go:127 +0xf4

Possible Solution:
Removing this piece of code:

goleak/options.go

Lines 159 to 161 in 1e9de54

if f := s.FirstFunction(); f != "runtime.goparkunlock" {
return false
}

@kapillamba4
Copy link
Author

cc @prashantv

@abhinav
Copy link
Collaborator

abhinav commented Sep 20, 2021

Thanks for reporting @kapillamba4. We'll look into this.

Internal ref: GO-887

sywhang added a commit that referenced this issue Sep 27, 2021
This fixes #66 .

On newer Go versions (1.16 onwards), the top of trace stacks is no longer runtime.goparkunlock. We had a logic that relied on this being the case, which made the tests to fail with -trace flag for newer Go versions. However, to maintain backwards compatibility, we shouldn't just remove this check.

This separates out the isTraceStack into a separate file that gets conditionally compiled on different Go versions (tracestack_old.go for Go 1.15 and before and tracestack_new.go for Go 1.16 and newer) to address this issue.

Internal Ref: GO-887.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants