On Thu, Oct 31, 2019 at 4:49 AM Xiangdong JI <xiangdong...@arm.com> wrote:
>
> A few 'print' statements in runtime for diagnosing result in panic like the 
> following, what could be the root cause? any alternatives to display g's 
> value?
> Thanks a lot.
>
> 1   g := getg()                                     // existing code
> 2   print(g, g.stack.lo, g.stack.hi)        // new line
>
> runtime: newstack at runtime.printlock+0x7c sp=0x400074cc40 
> stack=[0x40008d8000, 0x40008da000]
>         morebuf={pc:0x51bf8 sp:0x400074cc40 lr:0x0}
>         sched={pc:0x3dfdc sp:0x400074cc40 lr:0x51bf8 ctxt:0x0}
> runtime.sigtrampgo(0x11, 0x400074cda0, 0x400074ce20)
> runtime.sigtrampgo(0x11, 0x40003dcda0, 0x40003dce20)
>
> ........
>
> fatal error: runtime: stack split at bad time
> runtime: newstack at runtime.printlock+0x7c sp=0x4000442c40 
> stack=[0x4000818000, 0x400081a000]
>         morebuf={pc:0x51bf8 sp:0x4000442c40 lr:0x0}
>         sched={pc:0x3dfdc sp:0x4000442c40 lr:0x51bf8 ctxt:0x0}
> runtime.sigtrampgo(0x11, 0x4000442da0, 0x4000442e20)

sigtrampgo is invoked when a signal occurs.  There is very little that
you can safely do in sigtrampgo, because it could be interrupting any
arbitrary code.  You can't execute code that takes a lock, that checks
for a stack split, or that uses a write barrier.  If you need to
insert a debugging print in sigtrampgo, you need to make a direct call
to write1, probably passing a first argument of 2.

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/CAOyqgcVDYUuitF2Dc%2BpGL4kUVcKcSWJYYgn7GdYv%2B1pxQ%2Bd9aA%40mail.gmail.com.

Reply via email to