-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Code-Hex/vz segfaults when NewFileSerialPortAttachment returns an error #56
Comments
This fixes TestNonExistingFileSerialPortAttachment() which is crashing before this commit: % go test . fatal error: unexpected signal during runtime execution [signal SIGSEGV: segmentation violation code=0x2 addr=0xcf6cce7eb130 pc=0x19e33a5a0] runtime stack: runtime.throw({0x100ce0ded?, 0x100ccf234?}) /usr/local/go/src/runtime/panic.go:1047 +0x40 fp=0x16f293700 sp=0x16f2936d0 pc=0x100ba2870 runtime.sigpanic() /usr/local/go/src/runtime/signal_unix.go:819 +0x1e4 fp=0x16f293730 sp=0x16f293700 pc=0x100bb9754 goroutine 19 [syscall]: runtime.cgocall(0x100ccf214, 0x14000040d98) /usr/local/go/src/runtime/cgocall.go:158 +0x54 fp=0x14000040d60 sp=0x14000040d20 pc=0x100b6fbc4 github.com/Code-Hex/vz/v2._Cfunc_convertNSError2Flat(0x6000022cb120) _cgo_gotypes.go:344 +0x3c fp=0x14000040d90 sp=0x14000040d60 pc=0x100ccc11c github.com/Code-Hex/vz/v2.newNSError.func1(0x1010c0a68?) /Users/teuf/dev/vz/objcutil.go:234 +0x48 fp=0x14000040df0 sp=0x14000040d90 pc=0x100cccd58 github.com/Code-Hex/vz/v2.newNSError(0x0?) /Users/teuf/dev/vz/objcutil.go:234 +0x30 fp=0x14000040e80 sp=0x14000040df0 pc=0x100cccbe0 github.com/Code-Hex/vz/v2.NewFileSerialPortAttachment({0x100cd9765?, 0x100be659c?}, 0x68?) /Users/teuf/dev/vz/console.go:92 +0x104 fp=0x14000040f10 sp=0x14000040e80 pc=0x100ccc6c4 github.com/Code-Hex/vz/v2.TestNonExistingFileSerialPortAttachment(0x0?) /Users/teuf/dev/vz/error_test.go:10 +0x30 fp=0x14000040f60 sp=0x14000040f10 pc=0x100ccbf10 testing.tRunner(0x14000107040, 0x100d81878) /usr/local/go/src/testing/testing.go:1446 +0x10c fp=0x14000040fb0 sp=0x14000040f60 pc=0x100c2d10c testing.(*T).Run.func1() /usr/local/go/src/testing/testing.go:1493 +0x2c fp=0x14000040fd0 sp=0x14000040fb0 pc=0x100c2de4c runtime.goexit() /usr/local/go/src/runtime/asm_arm64.s:1165 +0x4 fp=0x14000040fd0 sp=0x14000040fd0 pc=0x100bd4834 created by testing.(*T).Run /usr/local/go/src/testing/testing.go:1493 +0x300 [snip] This fixes Code-Hex#56
This fixes TestNonExistingFileSerialPortAttachment() which is crashing before this commit: ``` % go test . fatal error: unexpected signal during runtime execution [signal SIGSEGV: segmentation violation code=0x2 addr=0xcf6cce7eb130 pc=0x19e33a5a0] runtime stack: runtime.throw({0x100ce0ded?, 0x100ccf234?}) /usr/local/go/src/runtime/panic.go:1047 +0x40 fp=0x16f293700 sp=0x16f2936d0 pc=0x100ba2870 runtime.sigpanic() /usr/local/go/src/runtime/signal_unix.go:819 +0x1e4 fp=0x16f293730 sp=0x16f293700 pc=0x100bb9754 goroutine 19 [syscall]: runtime.cgocall(0x100ccf214, 0x14000040d98) /usr/local/go/src/runtime/cgocall.go:158 +0x54 fp=0x14000040d60 sp=0x14000040d20 pc=0x100b6fbc4 github.com/Code-Hex/vz/v2._Cfunc_convertNSError2Flat(0x6000022cb120) _cgo_gotypes.go:344 +0x3c fp=0x14000040d90 sp=0x14000040d60 pc=0x100ccc11c github.com/Code-Hex/vz/v2.newNSError.func1(0x1010c0a68?) /Users/teuf/dev/vz/objcutil.go:234 +0x48 fp=0x14000040df0 sp=0x14000040d90 pc=0x100cccd58 github.com/Code-Hex/vz/v2.newNSError(0x0?) /Users/teuf/dev/vz/objcutil.go:234 +0x30 fp=0x14000040e80 sp=0x14000040df0 pc=0x100cccbe0 github.com/Code-Hex/vz/v2.NewFileSerialPortAttachment({0x100cd9765?, 0x100be659c?}, 0x68?) /Users/teuf/dev/vz/console.go:92 +0x104 fp=0x14000040f10 sp=0x14000040e80 pc=0x100ccc6c4 github.com/Code-Hex/vz/v2.TestNonExistingFileSerialPortAttachment(0x0?) /Users/teuf/dev/vz/error_test.go:10 +0x30 fp=0x14000040f60 sp=0x14000040f10 pc=0x100ccbf10 testing.tRunner(0x14000107040, 0x100d81878) /usr/local/go/src/testing/testing.go:1446 +0x10c fp=0x14000040fb0 sp=0x14000040f60 pc=0x100c2d10c testing.(*T).Run.func1() /usr/local/go/src/testing/testing.go:1493 +0x2c fp=0x14000040fd0 sp=0x14000040fb0 pc=0x100c2de4c runtime.goexit() /usr/local/go/src/runtime/asm_arm64.s:1165 +0x4 fp=0x14000040fd0 sp=0x14000040fd0 pc=0x100bd4834 created by testing.(*T).Run /usr/local/go/src/testing/testing.go:1493 +0x300 [snip] ``` This fixes Code-Hex#56
This problem should fix error handling instead of removing autorelease pool |
This commit is doing the same as 318c157 |
@cfergeau So why you send PR? I can't believe |
I wrote a test case to reproduce the issue. I found commit 318c157 . Your commit is also removing autoreleasepool (but the commit log does not explain why). My commit fixes the test case, and is similar to an existing commit, so it seemed good for sending. |
This fixes TestNonExistingFileSerialPortAttachment() which is crashing before this commit: ``` % go test . fatal error: unexpected signal during runtime execution [signal SIGSEGV: segmentation violation code=0x2 addr=0xcf6cce7eb130 pc=0x19e33a5a0] runtime stack: runtime.throw({0x100ce0ded?, 0x100ccf234?}) /usr/local/go/src/runtime/panic.go:1047 +0x40 fp=0x16f293700 sp=0x16f2936d0 pc=0x100ba2870 runtime.sigpanic() /usr/local/go/src/runtime/signal_unix.go:819 +0x1e4 fp=0x16f293730 sp=0x16f293700 pc=0x100bb9754 goroutine 19 [syscall]: runtime.cgocall(0x100ccf214, 0x14000040d98) /usr/local/go/src/runtime/cgocall.go:158 +0x54 fp=0x14000040d60 sp=0x14000040d20 pc=0x100b6fbc4 github.com/Code-Hex/vz/v2._Cfunc_convertNSError2Flat(0x6000022cb120) _cgo_gotypes.go:344 +0x3c fp=0x14000040d90 sp=0x14000040d60 pc=0x100ccc11c github.com/Code-Hex/vz/v2.newNSError.func1(0x1010c0a68?) /Users/teuf/dev/vz/objcutil.go:234 +0x48 fp=0x14000040df0 sp=0x14000040d90 pc=0x100cccd58 github.com/Code-Hex/vz/v2.newNSError(0x0?) /Users/teuf/dev/vz/objcutil.go:234 +0x30 fp=0x14000040e80 sp=0x14000040df0 pc=0x100cccbe0 github.com/Code-Hex/vz/v2.NewFileSerialPortAttachment({0x100cd9765?, 0x100be659c?}, 0x68?) /Users/teuf/dev/vz/console.go:92 +0x104 fp=0x14000040f10 sp=0x14000040e80 pc=0x100ccc6c4 github.com/Code-Hex/vz/v2.TestNonExistingFileSerialPortAttachment(0x0?) /Users/teuf/dev/vz/error_test.go:10 +0x30 fp=0x14000040f60 sp=0x14000040f10 pc=0x100ccbf10 testing.tRunner(0x14000107040, 0x100d81878) /usr/local/go/src/testing/testing.go:1446 +0x10c fp=0x14000040fb0 sp=0x14000040f60 pc=0x100c2d10c testing.(*T).Run.func1() /usr/local/go/src/testing/testing.go:1493 +0x2c fp=0x14000040fd0 sp=0x14000040fb0 pc=0x100c2de4c runtime.goexit() /usr/local/go/src/runtime/asm_arm64.s:1165 +0x4 fp=0x14000040fd0 sp=0x14000040fd0 pc=0x100bd4834 created by testing.(*T).Run /usr/local/go/src/testing/testing.go:1493 +0x300 [snip] ``` This fixes Code-Hex#56
I propose a working patch to fix a crash in Code-Hex/vz master with a reproducer. You reject it, which is fine. I am not asking for teaching of objective-c and Go, but I expect feedback I can act on. Then I can provide a PR which will suit you. Your feedback so far in this issue has been too vague and non actionable for me, especially with my lack of familiarity with objective-c. |
@cfergeau Test case welcome but no thank you third-party deps. I think I should fix the my code |
If VZFileSerialPortAttachment:initWithURL returns an error, we need to call `retain` on it, otherwise it will be freed when exiting from the @autoreleasepool block. This fixes TestNonExistingFileSerialPortAttachment() which is crashing before this commit: ``` % go test . fatal error: unexpected signal during runtime execution [signal SIGSEGV: segmentation violation code=0x2 addr=0xcf6cce7eb130 pc=0x19e33a5a0] runtime stack: runtime.throw({0x100ce0ded?, 0x100ccf234?}) /usr/local/go/src/runtime/panic.go:1047 +0x40 fp=0x16f293700 sp=0x16f2936d0 pc=0x100ba2870 runtime.sigpanic() /usr/local/go/src/runtime/signal_unix.go:819 +0x1e4 fp=0x16f293730 sp=0x16f293700 pc=0x100bb9754 goroutine 19 [syscall]: runtime.cgocall(0x100ccf214, 0x14000040d98) /usr/local/go/src/runtime/cgocall.go:158 +0x54 fp=0x14000040d60 sp=0x14000040d20 pc=0x100b6fbc4 github.com/Code-Hex/vz/v2._Cfunc_convertNSError2Flat(0x6000022cb120) _cgo_gotypes.go:344 +0x3c fp=0x14000040d90 sp=0x14000040d60 pc=0x100ccc11c github.com/Code-Hex/vz/v2.newNSError.func1(0x1010c0a68?) /Users/teuf/dev/vz/objcutil.go:234 +0x48 fp=0x14000040df0 sp=0x14000040d90 pc=0x100cccd58 github.com/Code-Hex/vz/v2.newNSError(0x0?) /Users/teuf/dev/vz/objcutil.go:234 +0x30 fp=0x14000040e80 sp=0x14000040df0 pc=0x100cccbe0 github.com/Code-Hex/vz/v2.NewFileSerialPortAttachment({0x100cd9765?, 0x100be659c?}, 0x68?) /Users/teuf/dev/vz/console.go:92 +0x104 fp=0x14000040f10 sp=0x14000040e80 pc=0x100ccc6c4 github.com/Code-Hex/vz/v2.TestNonExistingFileSerialPortAttachment(0x0?) /Users/teuf/dev/vz/error_test.go:10 +0x30 fp=0x14000040f60 sp=0x14000040f10 pc=0x100ccbf10 testing.tRunner(0x14000107040, 0x100d81878) /usr/local/go/src/testing/testing.go:1446 +0x10c fp=0x14000040fb0 sp=0x14000040f60 pc=0x100c2d10c testing.(*T).Run.func1() /usr/local/go/src/testing/testing.go:1493 +0x2c fp=0x14000040fd0 sp=0x14000040fb0 pc=0x100c2de4c runtime.goexit() /usr/local/go/src/runtime/asm_arm64.s:1165 +0x4 fp=0x14000040fd0 sp=0x14000040fd0 pc=0x100bd4834 created by testing.(*T).Run /usr/local/go/src/testing/testing.go:1493 +0x300 [snip] ``` This fixes Code-Hex#56
@cfergeau Please stop sending your PR to me. I have a plan to commit to this project. |
@cfergeau Not that it matters, but I don't know why my contribution to the repository is your business. It is annoying. |
Sorry, I filed PR #60 before seeing your message. You can ignore it until v3 is released! |
I checked this issue, and the If you want to send PR for this issue, I can accept your PR. Actually I want only this changes.
|
If we use autoreleasepool, the error returned from VZFileSerialPortAttachment:initWithURL will be freed before newVZFileSerialPortAttachment returns. We want the caller to be able to use it. This fixes TestNonExistingFileSerialPortAttachment() which is crashing before this commit: ``` % go test . fatal error: unexpected signal during runtime execution [signal SIGSEGV: segmentation violation code=0x2 addr=0xcf6cce7eb130 pc=0x19e33a5a0] runtime stack: runtime.throw({0x100ce0ded?, 0x100ccf234?}) /usr/local/go/src/runtime/panic.go:1047 +0x40 fp=0x16f293700 sp=0x16f2936d0 pc=0x100ba2870 runtime.sigpanic() /usr/local/go/src/runtime/signal_unix.go:819 +0x1e4 fp=0x16f293730 sp=0x16f293700 pc=0x100bb9754 goroutine 19 [syscall]: runtime.cgocall(0x100ccf214, 0x14000040d98) /usr/local/go/src/runtime/cgocall.go:158 +0x54 fp=0x14000040d60 sp=0x14000040d20 pc=0x100b6fbc4 github.com/Code-Hex/vz/v2._Cfunc_convertNSError2Flat(0x6000022cb120) _cgo_gotypes.go:344 +0x3c fp=0x14000040d90 sp=0x14000040d60 pc=0x100ccc11c github.com/Code-Hex/vz/v2.newNSError.func1(0x1010c0a68?) /Users/teuf/dev/vz/objcutil.go:234 +0x48 fp=0x14000040df0 sp=0x14000040d90 pc=0x100cccd58 github.com/Code-Hex/vz/v2.newNSError(0x0?) /Users/teuf/dev/vz/objcutil.go:234 +0x30 fp=0x14000040e80 sp=0x14000040df0 pc=0x100cccbe0 github.com/Code-Hex/vz/v2.NewFileSerialPortAttachment({0x100cd9765?, 0x100be659c?}, 0x68?) /Users/teuf/dev/vz/console.go:92 +0x104 fp=0x14000040f10 sp=0x14000040e80 pc=0x100ccc6c4 github.com/Code-Hex/vz/v2.TestNonExistingFileSerialPortAttachment(0x0?) /Users/teuf/dev/vz/error_test.go:10 +0x30 fp=0x14000040f60 sp=0x14000040f10 pc=0x100ccbf10 testing.tRunner(0x14000107040, 0x100d81878) /usr/local/go/src/testing/testing.go:1446 +0x10c fp=0x14000040fb0 sp=0x14000040f60 pc=0x100c2d10c testing.(*T).Run.func1() /usr/local/go/src/testing/testing.go:1493 +0x2c fp=0x14000040fd0 sp=0x14000040fb0 pc=0x100c2de4c runtime.goexit() /usr/local/go/src/runtime/asm_arm64.s:1165 +0x4 fp=0x14000040fd0 sp=0x14000040fd0 pc=0x100bd4834 created by testing.(*T).Run /usr/local/go/src/testing/testing.go:1493 +0x300 [snip] ``` This fixes Code-Hex#56
If we use autoreleasepool, the error returned from VZFileSerialPortAttachment:initWithURL will be freed before newVZFileSerialPortAttachment returns. We want the caller to be able to use it. This fixes TestNonExistingFileSerialPortAttachment() which is crashing before this commit: ``` % go test . fatal error: unexpected signal during runtime execution [signal SIGSEGV: segmentation violation code=0x2 addr=0xcf6cce7eb130 pc=0x19e33a5a0] runtime stack: runtime.throw({0x100ce0ded?, 0x100ccf234?}) /usr/local/go/src/runtime/panic.go:1047 +0x40 fp=0x16f293700 sp=0x16f2936d0 pc=0x100ba2870 runtime.sigpanic() /usr/local/go/src/runtime/signal_unix.go:819 +0x1e4 fp=0x16f293730 sp=0x16f293700 pc=0x100bb9754 goroutine 19 [syscall]: runtime.cgocall(0x100ccf214, 0x14000040d98) /usr/local/go/src/runtime/cgocall.go:158 +0x54 fp=0x14000040d60 sp=0x14000040d20 pc=0x100b6fbc4 github.com/Code-Hex/vz/v2._Cfunc_convertNSError2Flat(0x6000022cb120) _cgo_gotypes.go:344 +0x3c fp=0x14000040d90 sp=0x14000040d60 pc=0x100ccc11c github.com/Code-Hex/vz/v2.newNSError.func1(0x1010c0a68?) /Users/teuf/dev/vz/objcutil.go:234 +0x48 fp=0x14000040df0 sp=0x14000040d90 pc=0x100cccd58 github.com/Code-Hex/vz/v2.newNSError(0x0?) /Users/teuf/dev/vz/objcutil.go:234 +0x30 fp=0x14000040e80 sp=0x14000040df0 pc=0x100cccbe0 github.com/Code-Hex/vz/v2.NewFileSerialPortAttachment({0x100cd9765?, 0x100be659c?}, 0x68?) /Users/teuf/dev/vz/console.go:92 +0x104 fp=0x14000040f10 sp=0x14000040e80 pc=0x100ccc6c4 github.com/Code-Hex/vz/v2.TestNonExistingFileSerialPortAttachment(0x0?) /Users/teuf/dev/vz/error_test.go:10 +0x30 fp=0x14000040f60 sp=0x14000040f10 pc=0x100ccbf10 testing.tRunner(0x14000107040, 0x100d81878) /usr/local/go/src/testing/testing.go:1446 +0x10c fp=0x14000040fb0 sp=0x14000040f60 pc=0x100c2d10c testing.(*T).Run.func1() /usr/local/go/src/testing/testing.go:1493 +0x2c fp=0x14000040fd0 sp=0x14000040fb0 pc=0x100c2de4c runtime.goexit() /usr/local/go/src/runtime/asm_arm64.s:1165 +0x4 fp=0x14000040fd0 sp=0x14000040fd0 pc=0x100bd4834 created by testing.(*T).Run /usr/local/go/src/testing/testing.go:1493 +0x300 [snip] ``` This fixes Code-Hex#56
Done in #71. I left |
318c157 was probably fixing a similar issue.
The text was updated successfully, but these errors were encountered: