On Thu, Oct 31, 2019 at 4:49 AM Xiangdong JI <
xiangd...@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