From b9bdf597b0ff1d3183c179782c5cff2e5fc69643 Mon Sep 17 00:00:00 2001 From: Alessandro Arzilli Date: Tue, 21 Feb 2017 19:38:13 +0100 Subject: [PATCH] proc_test: TestStacktraceWithBarriers failing on go1.8 (#735) Changes to the GC in 1.8 make this test fail because the GC isn't inserting stack barriers into our test program anymore. This isn't the same thing as being unable to print stacktraces in presence of stack barriers so the test shouldn't fail. --- pkg/proc/proc_test.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/proc/proc_test.go b/pkg/proc/proc_test.go index 2ffadbf1..6847b239 100644 --- a/pkg/proc/proc_test.go +++ b/pkg/proc/proc_test.go @@ -2436,13 +2436,27 @@ func TestStacktraceWithBarriers(t *testing.T) { // stack frame with the address of runtime.stackBarrier. // The original return address is saved into the stkbar slice inside the G // struct. + + // In Go 1.8 stack barriers are not inserted by default, this enables them. + godebugOld := os.Getenv("GODEBUG") + defer os.Setenv("GODEBUG", godebugOld) + os.Setenv("GODEBUG", "gcrescanstacks=1") + + // TODO(aarzilli): in Go 1.9 stack barriers will be removed completely, therefore + // this test will have to be disabled + withTestProcess("binarytrees", t, func(p *Process, fixture protest.Fixture) { // We want to get a user goroutine with a stack barrier, to get that we execute the program until runtime.gcInstallStackBarrier is executed AND the goroutine it was executed onto contains a call to main.bottomUpTree _, err := setFunctionBreakpoint(p, "runtime.gcInstallStackBarrier") assertNoError(err, t, "setFunctionBreakpoint()") stackBarrierGoids := []int{} for len(stackBarrierGoids) == 0 { - assertNoError(p.Continue(), t, "Continue()") + err := p.Continue() + if _, exited := err.(ProcessExitedError); exited { + t.Logf("Could not run test") + return + } + assertNoError(err, t, "Continue()") gs, err := p.GoroutinesInfo() assertNoError(err, t, "GoroutinesInfo()") for _, th := range p.threads {