Skip to content

cmd/trace: failed to read event: expected batch event (EventBatch), got Invalid(115) #67602

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

Closed
codenoid opened this issue May 23, 2024 · 2 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.

Comments

@codenoid
Copy link

Go version

go version go1.22.1 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/user/Library/Caches/go-build'
GOENV='/Users/user/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/user/go/pkg/mod'
GONOPROXY='github.com/xx'
GONOSUMDB='github.com/xx'
GOOS='darwin'
GOPATH='/Users/user/go'
GOPRIVATE='github.com/xx'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.1'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/user/Documents/xx/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/kk/ypk1jlt93r9cgpc_nnx75q0w0000gn/T/go-build877092516=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

I basically generate golang trace file like this below:

package main

import (
    "os"
    "runtime/trace"
)

func main() {
    trace.Start(os.Stderr) //start the trace 
    defer trace.Stop() // defer to the end
    .... //rest of the code
}

run with:

go run ./cmd/app 2> trace.out
# then ctrl+c after doing some task

the trace.out file is generated

I'm sorry I can't put trace.out file publicly

What did you see happen?

when I want to see the trace using:

go tool trace trace.out

it's print

user@users-MacBook-Pro xx % go tool trace trace.out
2024/05/23 19:46:40 Preparing trace for viewer...
failed to read event: expected batch event (EventBatch), got Invalid(115)

What did you expect to see?

view the trace

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label May 23, 2024
@nsrip-dd
Copy link
Contributor

Deferred functions won't run if you stop your program with Ctrl-C. So, trace.Stop won't run and you will likely end up with an incomplete trace. #65319 is meant to address this, I think, as well as #65316 to make go tool trace handle incomplete traces better.

@codenoid
Copy link
Author

I see, I remove the usage of ctrl+c and it's loaded fine now, thankyou

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.
Projects
None yet
Development

No branches or pull requests

3 participants