8000 Panic when opening particular Go 1.25 trace · Issue #184 · dominikh/gotraceui · GitHub
[go: up one dir, main page]

Skip to content

Panic when opening particular Go 1.25 trace #184

Open

Description

@mark-rushakoff

I encountered this panic, running gotraceui from source at 40a0e49, using Go 1.25.2 for both running gotraceui and for producing my application's trace:

$ go run ./cmd/gotraceui/ /tmp/x.trace
# honnef.co/go/gotraceui/cmd/gotraceui
ld: warning: ignoring duplicate libraries: '-lobjc'
panic: runtime error: index out of range [-1]

goroutine 12 [running]:
honnef.co/go/gotraceui/trace/ptrace.processEvents(0x140000d2100, 0x1400061c000, 0x14000038908?)
	.../go/src/honnef.co/go/gotraceui/trace/ptrace/ptrace.go:661 +0x4d08
honnef.co/go/gotraceui/trace/ptrace.Parse(0x140000d2100, 0x140000100c0)
	.../go/src/honnef.co/go/gotraceui/trace/ptrace/ptrace.go:415 +0x1e0
main.loadTrace({_, _}, {_, _}, _)
	.../go/src/honnef.co/go/gotraceui/cmd/gotraceui/main.go:1490 +0x14c
main.(*MainWindow).OpenTrace(0x140000f9b08, {0x101122338, 0x14000148080})
	.../go/src/honnef.co/go/gotraceui/cmd/gotraceui/main.go:378 +0xd0
main.openTraceFromCmdline.func1()
	.../go/src/honnef.co/go/gotraceui/cmd/gotraceui/main.go:1299 +0x50
created by main.openTraceFromCmdline in goroutine 1
	.../go/src/honnef.co/go/gotraceui/cmd/gotraceui/main.go:1297 +0x19c
exit status 2

I was able to reproduce the troublesome trace it a couple times in a row with the particular benchmark I was developing, but then I tried changing a couple things, and then I was no longer able to generate an invalid trace.

I'm attaching a copy of the failed trace. I've redacted most of the strings related to the application, by overwriting application-specific strings with the same number of x characters (as in, the redacted file size is identical to the original).

redacted.trace.log

I was able to open the trace in gotraceui again by applying this change:

diff --git a/trace/ptrace/ptrace.go b/trace/ptrace/ptrace.go
index 2d59937..e1c5c50 100644
--- a/trace/ptrace/ptrace.go
+++ b/trace/ptrace/ptrace.go
@@ -658,6 +658,9 @@ func processEvents(r *exptrace.Reader, tr *Trace, progress func(float64)) error
                        case rangeScopeUnknown:
                                continue
                        case rangeScopeGC:
+                               if len(tr.GC) == 0 {
+                                       continue
+                               }
                                prev = &tr.GC[len(tr.GC)-1]
                        case rangeScopeSTW:
                                prev = &tr.STW[len(tr.STW)-1]

But I don't know if that is actually an appropriate fix, nor do I know enough about trace internals to say what's actually going on here.

Activity

  1. dominikh commented on Nov 25, 2025

    @dominikh
    Owner

    Thanks for the reproducer. I'll try to look into it asap.

  2. dominikh commented on Dec 15, 2025

    @dominikh
    Owner

    This has turned into a whole thing (golang/go#62627 (comment)) and a proper fix is waiting on changes to x/exp/trace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0