Random crashes caused by incorrect goroutine stack size detection
I'm encountering random crashes with my test application, which is essentially `blinky` on steroids. The app code is here: https://github.com/digitalentity/tinygo_gotchas/blob/master/src/ticker_crash/main.go. This is an extract from a different up to create a smaller repro environment.
Nothing really complicated, but it sometimes dies with a message `fatal error: undefined instruction with sp=0x20000fd4 pc=0x00000091` or similar to the console.
The biggest problem is that they are not deterministic - sometimes the app can run for hours, sometimes is crashes within minutes which makes debugging _really_ hard. Right now I have it running under GDB for about 1h without any sign of issue.
I never saw crashes when using `time.Sleep()`, it started when I started adding `time.Ticker` for a more accurate intervals. I can't use `Sleep` because I need to reasonably accurately run the closed loop controller every 2ms and this inverval needs to be measured more or less accurately.
I would appreciate any pointers.
关闭于 2026-06-08 18 条评论