Merge pull request #710 from visualfc/sigsegv
[wip] runtime: signal SIGSEGV
This commit is contained in:
@@ -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)))))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user