On Sat, Sep 23, 2023 at 10:32 PM zk Z <zzk819166...@gmail.com> wrote: > > I'm currently writing a Golang + CGO program, and will use posix ucontext in > CGO. Since all my core logic will be in the bind function of ucontext, we > should catch up all the bad code. And I test it by accessing to the null > pointer, which give me totally different behaviors that all depending on the > stack location which ucontext used. Here are more details with simplified > example. > > If I allocate the ucontext stack on the thread's stack, it will trigger > SIGSEGV. But if I allocate it on the heap, it will first trigger SIGSEGV, and > then SIGTRAP while calling `morestack_noctxt` before calling into > `runtime.sigpanic`. How can I fix this or how can I just get SIGSEGV? Why it > need morestack? > > Here is my guess, but seems not correct: when I used the malloc stack, it was > treat as it has stack overflow, and should more stack, but end up find it's > g0, then fatal. But it seems the goroutine's stack is much more lower address > than thread's stack?
This looks related to https://go.dev/issue/62130, which is partially fixed on tip. Perhaps you could try tip to see what happens? Ian -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcX9TZF%3DK4DumSXER4uzTnJOr739f9y58Zn10s8YaTLtNA%40mail.gmail.com.