Help debugging a SIGSEGV - "unexpected signal during runtime execution"

360 views
Skip to first unread message

Gerald Parker

unread,
Dec 8, 2022, 12:23:42 PM12/8/22
to golang-nuts
Hi all,
I'm using go version 1.19.4 darwin-amd64

I keep getting the following errors while trying to use a function from the robotgo package. I'm not experienced in C and could use some help trying to find the problem 

fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x10016df88]

runtime stack:
runtime.throw({0x1001c32bc?, 0x0?})
        /Users/gp/go/go1.19.4/src/runtime/panic.go:1047 +0x5d fp=0x7ff7bfeff520 sp=0x7ff7bfeff4f0 pc=0x10003751d
runtime.sigpanic()
        /Users/gp/go/go1.19.4/src/runtime/signal_unix.go:819 +0x369 fp=0x7ff7bfeff570 sp=0x7ff7bfeff520 pc=0x10004cf89

goroutine 1 [syscall]:
runtime.cgocall(0x10016df60, 0xc000187ce8)
        /Users/gp/go/go1.19.4/src/runtime/cgocall.go:158 +0x5c fp=0xc000187cc0 sp=0xc000187c88 pc=0x100006d1c
github.com/go-vgo/robotgo._Cfunc_keyCodeForChar(0x61)
        _cgo_gotypes.go:729 +0x47 fp=0xc000187ce8 sp=0xc000187cc0 pc=0x10016c527
github.com/go-vgo/robotgo.checkKeyCodes({0x1001b879b?, 0x1?})
        /Users/gp/Repositories/robotgo/key.go:344 +0x7f fp=0xc000187d40 sp=0xc000187ce8 pc=0x10016c89f
github.com/go-vgo/robotgo.keyTaps({0x1001b879b, 0x1}, {0x0?, 0x1?, 0x0?}, 0x8?)
        /Users/gp/Repositories/robotgo/key.go:402 +0x4d fp=0xc000187d78 sp=0xc000187d40 pc=0x10016ce2d
github.com/go-vgo/robotgo.KeyTap({0x1001b879b, 0x1}, {0x0?, 0x0, 0x0?})
        /Users/gp/Repositories/robotgo/key.go:519 +0x576 fp=0xc000187f28 sp=0xc000187d78 pc=0x10016d436
main.keyTap()
        /Users/gp/Repositories/robotgo/examples/key/main.go:47 +0x88 fp=0xc000187f70 sp=0xc000187f28 pc=0x10016d908
main.main()
        /Users/gp/Repositories/robotgo/examples/key/main.go:136 +0x17 fp=0xc000187f80 sp=0xc000187f70 pc=0x10016d937
runtime.main()
        /Users/gp/go/go1.19.4/src/runtime/proc.go:250 +0x212 fp=0xc000187fe0 sp=0xc000187f80 pc=0x100039d32
runtime.goexit()
        /Users/gp/go/go1.19.4/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000187fe8 sp=0xc000187fe0 pc=0x100066861

goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /Users/gp/go/go1.19.4/src/runtime/proc.go:363 +0xd6 fp=0xc000058fb0 sp=0xc000058f90 pc=0x10003a0f6
runtime.goparkunlock(...)
        /Users/gp/go/go1.19.4/src/runtime/proc.go:369
runtime.forcegchelper()
        /Users/gp/go/go1.19.4/src/runtime/proc.go:302 +0xad fp=0xc000058fe0 sp=0xc000058fb0 pc=0x100039f8d
runtime.goexit()
        /Users/gp/go/go1.19.4/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000058fe8 sp=0xc000058fe0 pc=0x100066861
created by runtime.init.6
        /Users/gp/go/go1.19.4/src/runtime/proc.go:290 +0x25

goroutine 3 [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /Users/gp/go/go1.19.4/src/runtime/proc.go:363 +0xd6 fp=0xc000059790 sp=0xc000059770 pc=0x10003a0f6
runtime.goparkunlock(...)
        /Users/gp/go/go1.19.4/src/runtime/proc.go:369
runtime.bgsweep(0x0?)
        /Users/gp/go/go1.19.4/src/runtime/mgcsweep.go:278 +0x8e fp=0xc0000597c8 sp=0xc000059790 pc=0x10002738e
runtime.gcenable.func1()
        /Users/gp/go/go1.19.4/src/runtime/mgc.go:178 +0x26 fp=0xc0000597e0 sp=0xc0000597c8 pc=0x10001c246
runtime.goexit()
        /Users/gp/go/go1.19.4/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0000597e8 sp=0xc0000597e0 pc=0x100066861
created by runtime.gcenable
        /Users/gp/go/go1.19.4/src/runtime/mgc.go:178 +0x6b

goroutine 4 [GC scavenge wait]:
runtime.gopark(0xc000024070?, 0x10020b4a8?, 0x1?, 0x0?, 0x0?)
        /Users/gp/go/go1.19.4/src/runtime/proc.go:363 +0xd6 fp=0xc000059f70 sp=0xc000059f50 pc=0x10003a0f6
runtime.goparkunlock(...)
        /Users/gp/go/go1.19.4/src/runtime/proc.go:369
runtime.(*scavengerState).park(0x10031a420)
        /Users/gp/go/go1.19.4/src/runtime/mgcscavenge.go:389 +0x53 fp=0xc000059fa0 sp=0xc000059f70 pc=0x100025433
runtime.bgscavenge(0x0?)
        /Users/gp/go/go1.19.4/src/runtime/mgcscavenge.go:617 +0x45 fp=0xc000059fc8 sp=0xc000059fa0 pc=0x100025a05
runtime.gcenable.func2()
        /Users/gp/go/go1.19.4/src/runtime/mgc.go:179 +0x26 fp=0xc000059fe0 sp=0xc000059fc8 pc=0x10001c1e6
runtime.goexit()
        /Users/gp/go/go1.19.4/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000059fe8 sp=0xc000059fe0 pc=0x100066861
created by runtime.gcenable
        /Users/gp/go/go1.19.4/src/runtime/mgc.go:179 +0xaa

goroutine 18 [finalizer wait]:
runtime.gopark(0x10031a820?, 0xc0001024e0?, 0x0?, 0x0?, 0xc000058770?)
        /Users/gp/go/go1.19.4/src/runtime/proc.go:363 +0xd6 fp=0xc000058628 sp=0xc000058608 pc=0x10003a0f6
runtime.goparkunlock(...)
        /Users/gp/go/go1.19.4/src/runtime/proc.go:369
runtime.runfinq()
        /Users/gp/go/go1.19.4/src/runtime/mfinal.go:180 +0x10f fp=0xc0000587e0 sp=0xc000058628 pc=0x10001b34f
runtime.goexit()
        /Users/gp/go/go1.19.4/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0000587e8 sp=0xc0000587e0 pc=0x100066861
created by runtime.createfing
        /Users/gp/go/go1.19.4/src/runtime/mfinal.go:157 +0x45

Process finished with the exit code 2

Kurtis Rader

unread,
Dec 8, 2022, 8:13:14 PM12/8/22
to Gerald Parker, golang-nuts
It superficially looks like you're running the code from https://github.com/go-vgo/robotgo/blob/master/examples/key/main.go. However, The line number 136 in main.go in the backtrace doesn't make any sense since the example code from the project only has 134 lines. Did you modify the example code? If so you'll need to show us your modifications. Does the example from that project work if you don't modify it?

Note that the SIGSEGV is because the code is trying to use the value 8 as an address. So it isn't a typical null/nil pointer dereference. Possibly you're passing something like a length of some object as an argument which should be the address of some object.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/d9276cb5-aa29-4fb7-8c9a-fde308252bden%40googlegroups.com.


--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

Gerald Parker

unread,
Dec 8, 2022, 11:42:17 PM12/8/22
to golang-nuts
Hi Kurtis,

Thanks for the response. To be clear this issue is the defect that I'm encountering. The issue was originally logged against v1.0.0-beta4. I am using v1.0.0-beta6 but the defect has not been fixed. 

This defect occurs when calling robotgo.KeyTap("a"). It doesn't just happen when passing in "a", it seems to occurs whenever any value other than a whitespace value is passed in. I noticed that it happens when calling the robotgo.KeyToggle function also.

To answer your question about the main function. Yes I did alter it. I just changed it to the following so that I could try and debug the issue:

func main() {
 robotgo.KeyTap("a")
}

On a side note. The reason I'm using v1.0.0-beta6 is because when I tried to import it into my original project by running go get -u github.com/go-vgo/robotgo the branch that was pulled has an entirely different set of issues. I had to specify the beta6 tag using go get -u github.com/go-vgo/rob...@1.0.0-beta6
Reply all
Reply to author
Forward
0 new messages