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

Delve getting stuck on intentional sigpanic trigger (via go-stack package) #594

Closed
ThomasDotCodes opened this issue Jul 13, 2016 · 8 comments

Comments

@ThomasDotCodes
Copy link

I'm using the log15 package for logging, which uses the go-stack package for stack tracing.

There is a particular line/method within the go-stack package that intentionally triggers a sigpanic:

https://github.com/go-stack/stack/blob/master/stack.go#L228

Due to this line, the debugger just keeps breaking at this same place over and over, and never allows me to continue or step over it, constantly printing out "continuing" from this line:

https://github.com/derekparker/delve/blob/master/service/debugger/debugger.go#L393

Not sure where to start in troubleshooting this.

@ThomasDotCodes ThomasDotCodes changed the title Delve getting stuck on intentional signapnic trigger (via go-stack package) Delve getting stuck on intentional signpanic trigger (via go-stack package) Jul 13, 2016
@ThomasDotCodes ThomasDotCodes changed the title Delve getting stuck on intentional signpanic trigger (via go-stack package) Delve getting stuck on intentional sigpanic trigger (via go-stack package) Jul 13, 2016
@aarzilli
Copy link
Member

What operating system are you using? Can you give me some step to reproduce this problem?
I tried with this sample program:

package main

import (
    "fmt"

    "github.com/go-stack/stack"
)

func main() {
    s := stack.Trace().TrimRuntime()
    fmt.Printf("%v\n", s)
}

but I have no problem debugging it.

@LeeWong
Copy link

LeeWong commented Sep 10, 2016

I am facing the same issue on windows 10 and here is the output of go env

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=...\go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=...\AppData\Local\Temp\go-build500025894=/tmp/go-build -gno-record-gcc-switches
set CXX=g++
set CGO_ENABLED=1

the file I try to debug is
https://github.com/go-kit/kit/blob/master/examples/stringsvc1/main.go

The delve debug output:
github.com/go-stack/stack.findSigpanic.func1() .../go/src/github.com/go-stack/stack/stack.go:228 (PC: 0x5faf0a)
223: }
224: }
225: }
226: }()
227: // intentional nil pointer dereference to trigger sigpanic

228: return *p
229: }()
230: return fn
231: }
232:
233: var sigpanic = findSigpanic()

@aarzilli
Copy link
Member

I'm going to assume the original issue was about windows as well.

@BardoBravo
Copy link

Hi,
I also had the same issue when using go-lang debugger in Visual Code - Win10 by the way.
Hugs

@natdm
Copy link

natdm commented May 12, 2017

I'm having the same issue.

go version: go1.8.1 darwin/amd64
OS: macOS
Text Editor: Atom
Delve Debugger Version: 0.12.2

Debug logs show:

Starting delve with config "Debug"
API server listening at: 127.0.0.1:2345
Started delve with config "Debug"
Adding breakpoint @ bindings/http_binding.go:57
Added breakpoint @ bindings/http_binding.go:57

Breakpoints show my breakpoint, but it doesn't get reached. It gets stuck at gopkg.in/stack.v1/stack.go#L228

// findSigpanic intentionally executes faulting code to generate a stack trace
// containing an entry for runtime.sigpanic.
func findSigpanic() *runtime.Func {
	var fn *runtime.Func
	var p *int
	func() int {
		defer func() {
			if p := recover(); p != nil {
				var pcs [512]uintptr
				n := runtime.Callers(2, pcs[:])
				for _, pc := range pcs[:n] {
					f := runtime.FuncForPC(pc)
					if f.Name() == "runtime.sigpanic" {
						fn = f
						break
					}
				}
			}
		}()
		// intentional nil pointer dereference to trigger sigpanic
		return *p // LINE 228
	}()
	return fn
}

Here is a repo I made to duplicate the issue. It uses glide package manager to ensure dependencies are the same.
https://github.com/natdm/findsigpanic_recreation

@aarzilli
Copy link
Member

This can't be supported on the lldb backend, either switch to the native backend or do not use go-stack.

@dkushner
Copy link

I've opened this issue on go-stack to address this. Is there any way, in the mean time, to force delve to ignore either this specific exception or this file/package entirely to continue debugging? I'm guessing not, since the issue appears to be related to the fact that LLVM cannot intercept this signal at all, but worth a shot.

@aarzilli
Copy link
Member

No, sorry.

abner-chenc pushed a commit to loongson/delve that referenced this issue Mar 1, 2024
…o-delve#598)

* proc: changed windows backend to deal with simultaneous breakpoints

* bugfix: forgot to add windowsPrologue3 to the prologues list in e4c7df1

* Tolerate errors returned by Stacktrace in TestStacktraceGoroutine.

* bugfix: proc: propagate debug events we don't cause back to the target process

Fixes: go-delve#594

* proc: fixed TestStepConcurrentPtr

Implementation of nextInProgress was wrong.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants