cgo and fatal: morestack on g0

554 views
Skip to first unread message

Miha Vrhovnik

unread,
Aug 26, 2021, 7:55:47 AM8/26/21
to golang-nuts

Hey,

we are using a library via CGO that is the emulator for a real device.
That library also contains a javascript engine which calls to Go for communication to the outside world. The problem we are facing is that we are getting more and more crashes with "morestack on g0".
I have found tickets on the go github (for windows) that show that this occurs where go is out of stack. When looking at the gdb bt, the callstack doesn't seem so deep.
And before anyone asks, yes the call stack looks like this  go->c->c->.........->c->go (crash).

The main is locked to the Os thread with runtime.LockOSThread() however removing this doesn't help.

Is there any chance of upping up the available stack in CGO cases.

The behavior is the same on 1.16.7 and newly released 1.17.

BR,
Miha

Ian Lance Taylor

unread,
Sep 10, 2021, 6:02:20 PM9/10/21
to Miha Vrhovnik, golang-nuts
You didn't mention what kind of system you are using. When a Go
program uses cgo, the C threads will be created with the default stack
size for that system. Many systems have a way to configure this value
independently of the program. For example, on Linux, use ulimit -s.

Ian
Reply all
Reply to author
Forward
0 new messages