Merge pull request #710 from visualfc/sigsegv

[wip] runtime: signal SIGSEGV
This commit is contained in:
xushiwei
2024-08-14 15:09:10 +08:00
committed by GitHub
4 changed files with 71 additions and 0 deletions

View File

@@ -21,6 +21,8 @@ import (
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/c/pthread"
"github.com/goplus/llgo/c/signal"
"github.com/goplus/llgo/c/syscall"
)
// -----------------------------------------------------------------------------
@@ -116,4 +118,16 @@ const MaxZero = 1024
var ZeroVal [MaxZero]byte
func init() {
signal.Signal(c.Int(syscall.SIGSEGV), func(v c.Int) {
switch syscall.Signal(v) {
case syscall.SIGSEGV:
panic(errorString("invalid memory address or nil pointer dereference"))
default:
var buf [20]byte
panic(errorString("unexpected signal value: " + string(itoa(buf[:], uint64(v)))))
}
})
}
// -----------------------------------------------------------------------------