debugger: fix nil pointer dereference in FunctionReturnLocations
Fixes #1787
This commit is contained in:
parent
35d168ac16
commit
035190c292
@ -237,6 +237,9 @@ const deferReturn = "runtime.deferreturn"
|
||||
// for the given function, a list of addresses corresponding
|
||||
// to 'ret' or 'call runtime.deferreturn'.
|
||||
func (d *Debugger) FunctionReturnLocations(fnName string) ([]uint64, error) {
|
||||
d.processMutex.Lock()
|
||||
defer d.processMutex.Unlock()
|
||||
|
||||
var (
|
||||
p = d.target
|
||||
g = p.SelectedGoroutine()
|
||||
@ -249,7 +252,7 @@ func (d *Debugger) FunctionReturnLocations(fnName string) ([]uint64, error) {
|
||||
|
||||
var regs proc.Registers
|
||||
var mem proc.MemoryReadWriter = p.CurrentThread()
|
||||
if g.Thread != nil {
|
||||
if g != nil && g.Thread != nil {
|
||||
mem = g.Thread
|
||||
regs, _ = g.Thread.Registers(false)
|
||||
}
|
||||
|
@ -1810,3 +1810,13 @@ func TestRerecord(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestIssue1787(t *testing.T) {
|
||||
// Calling FunctionReturnLocations without a selected goroutine should
|
||||
// work.
|
||||
withTestClient2("testnextprog", t, func(c service.Client) {
|
||||
if c, _ := c.(*rpc2.RPCClient); c != nil {
|
||||
c.FunctionReturnLocations("main.main")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user