Skip to content
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

Start with -race results in segmentation violation #1774

Open
1 of 5 tasks
StarpTech opened this issue Jan 12, 2025 · 2 comments
Open
1 of 5 tasks

Start with -race results in segmentation violation #1774

StarpTech opened this issue Jan 12, 2025 · 2 comments

Comments

@StarpTech
Copy link

Describe the bug

We wanted to upgrade from v3 to v4 and run into the following issue (no other changes has been made and rollbacking the version fix the error)

To Reproduce

The binary is not starting at all kills itself before.

CGO_ENABLED=0 go run -race cmd/router/main.go
SIGSEGV: segmentation violation
PC=0x10417823c m=0 sigcode=2 addr=0x10
signal arrived during cgo execution

goroutine 1 gp=0xc0000021c0 m=0 mp=0x1079539a0 [syscall, locked to thread]:
runtime.cgocall(0x104e0efc0, 0x0)
        /usr/local/go/src/runtime/cgocall.go:167 +0x58 fp=0xc00009df40 sp=0xc00009df00 pc=0x1042291c8
runtime.main()
        /usr/local/go/src/runtime/proc.go:243 +0x210 fp=0xc00009dfd0 sp=0xc00009df40 pc=0x1041f5f40
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm64.s:1223 +0x4 fp=0xc00009dfd0 sp=0xc00009dfd0 pc=0x104238ea4

goroutine 2 gp=0xc000002c40 m=nil [force gc (idle)]:
runtime.gopark(0x0?, 0x1077f52e0?, 0xa0?, 0x39?, 0x0?)
        /usr/local/go/src/runtime/proc.go:424 +0xc8 fp=0xc000088790 sp=0xc000088770 pc=0x10422fe68
runtime.goparkunlock(...)
        /usr/local/go/src/runtime/proc.go:430
runtime.forcegchelper()
        /usr/local/go/src/runtime/proc.go:337 +0xb8 fp=0xc0000887d0 sp=0xc000088790 pc=0x1041f6328
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm64.s:1223 +0x4 fp=0xc0000887d0 sp=0xc0000887d0 pc=0x104238ea4
created by runtime.init.7 in goroutine 1
        /usr/local/go/src/runtime/proc.go:325 +0x24

goroutine 3 gp=0xc000003180 m=nil [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /usr/local/go/src/runtime/proc.go:424 +0xc8 fp=0xc000098f60 sp=0xc000098f40 pc=0x10422fe68
runtime.goparkunlock(...)
        /usr/local/go/src/runtime/proc.go:430
runtime.bgsweep(0xc0000b4000)
        /usr/local/go/src/runtime/mgcsweep.go:277 +0xa0 fp=0xc000098fb0 sp=0xc000098f60 pc=0x1041de0b0
runtime.gcenable.gowrap1()
        /usr/local/go/src/runtime/mgc.go:204 +0x28 fp=0xc000098fd0 sp=0xc000098fb0 pc=0x1041d1f38
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm64.s:1223 +0x4 fp=0xc000098fd0 sp=0xc000098fd0 pc=0x104238ea4
created by runtime.gcenable in goroutine 1
        /usr/local/go/src/runtime/mgc.go:204 +0x6c

goroutine 4 gp=0xc000003340 m=nil [GC scavenge wait]:
runtime.gopark(0xc0000b4000?, 0x1064f3048?, 0x1?, 0x0?, 0xc000003340?)
        /usr/local/go/src/runtime/proc.go:424 +0xc8 fp=0xc000194f60 sp=0xc000194f40 pc=0x10422fe68
runtime.goparkunlock(...)
        /usr/local/go/src/runtime/proc.go:430
runtime.(*scavengerState).park(0x1079523c0)
        /usr/local/go/src/runtime/mgcscavenge.go:425 +0x5c fp=0xc000194f90 sp=0xc000194f60 pc=0x1041dbaac
runtime.bgscavenge(0xc0000b4000)
        /usr/local/go/src/runtime/mgcscavenge.go:653 +0x44 fp=0xc000194fb0 sp=0xc000194f90 pc=0x1041dbff4
runtime.gcenable.gowrap2()
        /usr/local/go/src/runtime/mgc.go:205 +0x28 fp=0xc000194fd0 sp=0xc000194fb0 pc=0x1041d1ed8
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm64.s:1223 +0x4 fp=0xc000194fd0 sp=0xc000194fd0 pc=0x104238ea4
created by runtime.gcenable in goroutine 1
        /usr/local/go/src/runtime/mgc.go:205 +0xac

r0      0x0
r1      0x104e0efd0
r2      0xc00009def0
r3      0x107952d00
r4      0x110
r5      0xc00009d000
r6      0x1
r7      0x0
r8      0x1079539a0
r9      0x10417822c
r10     0x1079539a0
r11     0x107952d00
r12     0x1000000000000000
r13     0x16bc8afb0
r14     0xffffff0000000000
r15     0x7fb
r16     0xc00009d6c0
r17     0x1f555acc0
r18     0x0
r19     0x104e0efd0
r20     0x0
r21     0x16bc8af90
r22     0x107987484
r23     0x16bc8b118
r24     0x1832c2000
r25     0x0
r26     0x1069763c8
r27     0x107987000
r28     0x107952d00
r29     0x16bc8af28
lr      0x104239ca8
sp      0x16bc8af00
pc      0x10417823c
fault   0x10
exit status 2

Expected behavior
[A clear and concise description of what you expected to happen.]

Environment (please complete the following information):

  • Windows: [paste the result of ver]
  • Linux: [paste contents of /etc/os-release and the result of uname -a]
  • Mac OS: [paste the result of sw_vers and uname -a
  • FreeBSD: [paste the result of freebsd-version -k -r -u and uname -a]
  • OpenBSD: [paste the result of uname -a]
ProductName:            macOS
ProductVersion:         15.2
BuildVersion:           24C101

Darwin dustin 24.2.0 Darwin Kernel Version 24.2.0: Fri Dec  6 19:02:12 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6031 arm64

Additional context
[Cross-compiling? Paste the command you are using to cross-compile and the result of the corresponding go env]

@shirou
Copy link
Owner

shirou commented Jan 12, 2025

The content of the cmd/router/main.go is unclear to us, but based solely on this error, it seems unrelated to gopsutil. Could you provide a minimal reproducible example? Also, please let us know the version of Go and gopsutil you are using.

@dmathieu
Copy link

I am getting this segfault on an ARM mac just by running the gopsutil tests with CGO_ENABLED=0 and -race.

SIGSEGV: segmentation violation
PC=0x1007bc23c m=0 sigcode=2 addr=0x10
signal arrived during cgo execution

goroutine 1 gp=0xc0000021c0 m=0 mp=0x100cff7e0 [syscall, locked to thread]:
runtime.cgocall(0x1009abb80, 0x0)
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/cgocall.go:167 +0x58 fp=0xc000067f40 sp=0xc000067f00 pc=0x1008695d8
runtime.main()
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/proc.go:243 +0x210 fp=0xc000067fd0 sp=0xc000067f40 pc=0x100836c60
runtime.goexit({})
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/asm_arm64.s:1223 +0x4 fp=0xc000067fd0 sp=0xc000067fd0 pc=0x100877ec4

goroutine 2 gp=0xc000002c40 m=nil [force gc (idle)]:
runtime.gopark(0x0?, 0x100cbd280?, 0xe0?, 0xf7?, 0x0?)
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/proc.go:424 +0xc8 fp=0xc000052790 sp=0xc000052770 pc=0x10086faf8
runtime.goparkunlock(...)
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/proc.go:430
runtime.forcegchelper()
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/proc.go:337 +0xb8 fp=0xc0000527d0 sp=0xc000052790 pc=0x100837048
runtime.goexit({})
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/asm_arm64.s:1223 +0x4 fp=0xc0000527d0 sp=0xc0000527d0 pc=0x100877ec4
created by runtime.init.7 in goroutine 1
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/proc.go:325 +0x24

goroutine 3 gp=0xc000003180 m=nil [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/proc.go:424 +0xc8 fp=0xc000062f60 sp=0xc000062f40 pc=0x10086faf8
runtime.goparkunlock(...)
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/proc.go:430
runtime.bgsweep(0xc00007e000)
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/mgcsweep.go:277 +0xa0 fp=0xc000062fb0 sp=0xc000062f60 pc=0x10081f3e0
runtime.gcenable.gowrap1()
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/mgc.go:204 +0x28 fp=0xc000062fd0 sp=0xc000062fb0 pc=0x100813338
runtime.goexit({})
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/asm_arm64.s:1223 +0x4 fp=0xc000062fd0 sp=0xc000062fd0 pc=0x100877ec4
created by runtime.gcenable in goroutine 1
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/mgc.go:204 +0x6c

goroutine 4 gp=0xc000003340 m=nil [GC scavenge wait]:
runtime.gopark(0xc00007e000?, 0x100ada2a0?, 0x1?, 0x0?, 0xc000003340?)
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/proc.go:424 +0xc8 fp=0xc000068f60 sp=0xc000068f40 pc=0x10086faf8
runtime.goparkunlock(...)
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/proc.go:430
runtime.(*scavengerState).park(0x100cfed20)
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/mgcscavenge.go:425 +0x5c fp=0xc000068f90 sp=0xc000068f60 pc=0x10081cddc
runtime.bgscavenge(0xc00007e000)
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/mgcscavenge.go:653 +0x44 fp=0xc000068fb0 sp=0xc000068f90 pc=0x10081d324
runtime.gcenable.gowrap2()
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/mgc.go:205 +0x28 fp=0xc000068fd0 sp=0xc000068fb0 pc=0x1008132d8
runtime.goexit({})
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/asm_arm64.s:1223 +0x4 fp=0xc000068fd0 sp=0xc000068fd0 pc=0x100877ec4
created by runtime.gcenable in goroutine 1
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/mgc.go:205 +0xac

r0      0x0
r1      0x1009abb90
r2      0xc000067ef0
r3      0x100cfef40
r4      0x110
r5      0xc000067000
r6      0x1
r7      0x0
r8      0x100cff7e0
r9      0x1007bc22c
r10     0x100cff7e0
r11     0x100cfef40
r12     0x1000000000000000
r13     0x16f646cb0
r14     0xffffff0000000000
r15     0x7fb
r16     0xc0000676c0
r17     0x2091a6cc0
r18     0x0
r19     0x1009abb90
r20     0x0
r21     0x16f646c90
r22     0x100d3160c
r23     0x16f646e18
r24     0x196f0e000
r25     0x0
r26     0x100b51fb8
r27     0x100d31000
r28     0x100cfef40
r29     0x16f646c28
lr      0x100878cc8
sp      0x16f646c00
pc      0x1007bc23c
fault   0x10
FAIL    github.com/shirou/gopsutil/v4/process   1.430s
SIGSEGV: segmentation violation
PC=0x1044c423c m=0 sigcode=2 addr=0x10
signal arrived during cgo execution

goroutine 1 gp=0xc0000021c0 m=0 mp=0x104830ee0 [syscall, locked to thread]:
runtime.cgocall(0x104680750, 0x0)
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/cgocall.go:167 +0x58 fp=0xc000067f40 sp=0xc000067f00 pc=0x10456ea48
runtime.main()
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/proc.go:243 +0x210 fp=0xc000067fd0 sp=0xc000067f40 pc=0x10453da10
runtime.goexit({})
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/asm_arm64.s:1223 +0x4 fp=0xc000067fd0 sp=0xc000067fd0 pc=0x10457c504

goroutine 2 gp=0xc000002c40 m=nil [force gc (idle)]:
runtime.gopark(0x0?, 0x10480ce80?, 0xe0?, 0xe?, 0x0?)
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/proc.go:424 +0xc8 fp=0xc000052790 sp=0xc000052770 pc=0x104574448
runtime.goparkunlock(...)
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/proc.go:430
runtime.forcegchelper()
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/proc.go:337 +0xb8 fp=0xc0000527d0 sp=0xc000052790 pc=0x10453ddf8
runtime.goexit({})
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/asm_arm64.s:1223 +0x4 fp=0xc0000527d0 sp=0xc0000527d0 pc=0x10457c504
created by runtime.init.7 in goroutine 1
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/proc.go:325 +0x24

goroutine 18 gp=0xc00008a380 m=nil [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/proc.go:424 +0xc8 fp=0xc000062f60 sp=0xc000062f40 pc=0x104574448
runtime.goparkunlock(...)
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/proc.go:430
runtime.bgsweep(0xc000098000)
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/mgcsweep.go:277 +0xa0 fp=0xc000062fb0 sp=0xc000062f60 pc=0x104526b30
runtime.gcenable.gowrap1()
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/mgc.go:204 +0x28 fp=0xc000062fd0 sp=0xc000062fb0 pc=0x10451ab08
runtime.goexit({})
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/asm_arm64.s:1223 +0x4 fp=0xc000062fd0 sp=0xc000062fd0 pc=0x10457c504
created by runtime.gcenable in goroutine 1
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/mgc.go:204 +0x6c

goroutine 19 gp=0xc00008a540 m=nil [GC scavenge wait]:
runtime.gopark(0xc000098000?, 0x1046cc1b8?, 0x1?, 0x0?, 0xc00008a540?)
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/proc.go:424 +0xc8 fp=0xc0000a4f60 sp=0xc0000a4f40 pc=0x104574448
runtime.goparkunlock(...)
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/proc.go:430
runtime.(*scavengerState).park(0x104830420)
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/mgcscavenge.go:425 +0x5c fp=0xc0000a4f90 sp=0xc0000a4f60 pc=0x10452452c
runtime.bgscavenge(0xc000098000)
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/mgcscavenge.go:653 +0x44 fp=0xc0000a4fb0 sp=0xc0000a4f90 pc=0x104524a74
runtime.gcenable.gowrap2()
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/mgc.go:205 +0x28 fp=0xc0000a4fd0 sp=0xc0000a4fb0 pc=0x10451aaa8
runtime.goexit({})
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/asm_arm64.s:1223 +0x4 fp=0xc0000a4fd0 sp=0xc0000a4fd0 pc=0x10457c504
created by runtime.gcenable in goroutine 1
        /opt/homebrew/Cellar/go/1.23.4_1/libexec/src/runtime/mgc.go:205 +0xac

r0      0x0
r1      0x104680760
r2      0xc000067ef0
r3      0x104830640
r4      0x110
r5      0xc000067000
r6      0x1
r7      0x0
r8      0x104830ee0
r9      0x1044c422c
r10     0x104830ee0
r11     0x104830640
r12     0x1000000000000000
r13     0x16b93ecb0
r14     0xffffff0000000000
r15     0x7fb
r16     0xc0000676c0
r17     0x2091a6cc0
r18     0x0
r19     0x104680760
r20     0x0
r21     0x16b93ec90
r22     0x1048622dc
r23     0x16b93ee18
r24     0x196f0e000
r25     0x0
r26     0x104717e70
r27     0x104862000
r28     0x104830640
r29     0x16b93ec28
lr      0x10457d2f8
sp      0x16b93ec00
pc      0x1044c423c
fault   0x10
FAIL    github.com/shirou/gopsutil/v4/sensors   1.557s
FAIL

Output truncated, but the same segfault happens for every package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants