skywalking
skywalking copied to clipboard
[Bug] runtime execution with go race
Search before asking
- [X] I had searched in the issues and found no similar issues.
Apache SkyWalking Component
Go Agent (apache/skywalking-go)
What happened
After adding the -race parameter to the compilation command, running the compilation result will result in a runtime error when creating the span
What you expected to happen
Hope it works normally, only print DATA RACE information
How to reproduce
Use a simple web service program, the code is as follows:
package main
import (
_ "github.com/apache/skywalking-go"
"log"
"net/http"
)
func main() {
http.HandleFunc("/ping", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("ok"))
})
err := http.ListenAndServe(":8088", nil)
if err != nil {
log.Printf("server error: %s", err)
}
}
Run the compilation command as follows:
go build -toolexec="github/skywalking-go/bin/skywalking-go-agent--darwin-arm64" -a -race -o main main.go
Run the program:
./main
Send Request:
curl --location 'http://localhost:8088/ping'
Then the program exits with an error:
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x2 addr=0x10 pc=0x102f93f3c]
runtime stack:
runtime.throw({0x10367c717?, 0x0?})
/go1.20/go1.20.14/src/runtime/panic.go:1047 +0x40 fp=0x16ce6f170 sp=0x16ce6f140 pc=0x1030068a0
runtime.sigpanic()
/go1.20/go1.20.14/src/runtime/signal_unix.go:825 +0x244 fp=0x16ce6f1b0 sp=0x16ce6f170 pc=0x10301eb74
goroutine 10 [running]:
runtime.systemstack_switch()
/go1.20/go1.20.14/src/runtime/asm_arm64.s:200 +0x8 fp=0xc0000a75b0 sp=0xc0000a75a0 pc=0x1030393a8
runtime.newproc(0x0?)
/go1.20/go1.20.14/src/runtime/proc.go:4264 +0x48 fp=0xc0000a75f0 sp=0xc0000a75b0 pc=0x103012058
github.com/apache/skywalking-go/agent/core.(*RootSegmentSpan).end0(0xc000442b70)
span_tracing.go:258 +0x88 fp=0xc0000a7630 sp=0xc0000a75f0 pc=0x10364f528
github.com/apache/skywalking-go/agent/core.(*RootSegmentSpan).End(0xc000442b70)
span_tracing.go:247 +0xfc fp=0xc0000a7680 sp=0xc0000a7630 pc=0x10364f36c
net/http.(*skywalking_operatorTypeTracingSpanWrapper).End(0xc0004348a0)
Anything else
No response
Are you willing to submit a pull request to fix on your own?
- [ ] Yes I am willing to submit a pull request on my own!
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
go version: go1.20.14 agent version: v0.4.0
I haven't found the reason for the program break. But when I upgraded the go version to 1.23.0, the problem have resolved.
@zealotjx Could you try the latest codes?