Skip to content

Commit 6ef2e93

Browse files
committed
Fix code broken by the new Go SSA enabled compiler optimizations.
1 parent 03cd31e commit 6ef2e93

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

stack.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,11 @@ func (cs CallStack) Format(s fmt.State, verb rune) {
236236
s.Write(closeBracketBytes)
237237
}
238238

239-
// findSigpanic intentially executes faulting code to generate a stack trace
239+
// findSigpanic intentionally executes faulting code to generate a stack trace
240240
// containing an entry for runtime.sigpanic.
241241
func findSigpanic() *runtime.Func {
242242
var fn *runtime.Func
243+
var p *int
243244
func() int {
244245
defer func() {
245246
if p := recover(); p != nil {
@@ -254,9 +255,8 @@ func findSigpanic() *runtime.Func {
254255
}
255256
}
256257
}()
257-
// intentional division by zero fault
258-
a, b := 1, 0
259-
return a / b
258+
// intentional nil pointer dereference to trigger sigpanic
259+
return *p
260260
}()
261261
return fn
262262
}

0 commit comments

Comments
 (0)