Skip to content

Stack trace on panic loops forever #18286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
kristoff-it opened this issue Dec 15, 2023 · 2 comments
Open

Stack trace on panic loops forever #18286

kristoff-it opened this issue Dec 15, 2023 · 2 comments
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@kristoff-it
Copy link
Member

kristoff-it commented Dec 15, 2023

Zig Version

0.12.0-dev.1751+7fbbeae617

Steps to Reproduce and Observed Behavior

Switch to this branch if not merged yet: #18262

(note that the branch fixes issues with the build system that have nothing to do with this bug report)

git clone https://github.com/kristoff-it/zine.git
cd zine
git switch looping-trace
cd sample_website

Running Zig build at this point causes on my machine to hit an assertion in my code, which starts printing a stacktrace stuck on the same frame forever.

thread 421506 panic: reached unreachable code
/home/kristoff/zig/lib/std/debug.zig:342:14: 0x250f43 in assert (super)
    if (!ok) unreachable; // assertion failure
             ^
/home/kristoff/zig/lib/std/debug.zig:342:14: 0x250f43 in assert (super)
    if (!ok) unreachable; // assertion failure
             ^
/home/kristoff/zig/lib/std/debug.zig:342:14: 0x250f43 in assert (super)
    if (!ok) unreachable; // assertion failure
             ^
/home/kristoff/zig/lib/std/debug.zig:342:14: 0x250f43 in assert (super)
    if (!ok) unreachable; // assertion failure
             ^
/home/kristoff/zig/lib/std/debug.zig:342:14: 0x250f43 in assert (super)
    if (!ok) unreachable; // assertion failure

My machine is a NixOS VM running on aarch64 (Mac Mini M2).
In some other circumstances the stack trace fails to print completely.

Expected Behavior

The stack trace should end at some point.

@kristoff-it kristoff-it added the bug Observed behavior contradicts documented or intended behavior label Dec 15, 2023
@mitchellh
Copy link
Contributor

mitchellh commented May 19, 2025

This happens to me under a similar setup: NixOS in a VM on aarch64 Mac hardware. And another contributor under the same setup can confirm this also happening.

This makes developing and testing very difficult because not only do crashes do this but test failures also trigger this, so we can't even see what tests fail. We're resorting to printf-style development which is less than ideal. 😄

This happened to me starting with 0.13 but is still happening with 0.14.

EDIT: To reproduce:

  1. Clone Ghostty: https://github.com/ghostty-org/ghostty
  2. Add a if (true) @panic("OW"); at the start of main in src/main_ghostty.zig
  3. zig build run

(On aarch64-linux on Mac hardware, not sure if a VM is required but we've only reproduced in a VM thus far, haven't tried bare metal)

@rootbeer
Copy link
Contributor

I have a Draft PR that might happen to band-aid this bug: #23927 It puts an iteration limit on the std.debug stack trace dumping calls. The PR is currently a Draft because getting the expanded tests to pass everywhere might take me a while. I'm pretty confident in the loop-prevention fix (you can cherry-pick just that commit if you want to try it out).

Fixing the cause of the looping is probably also worth fixing, but I don't have ideas on how to accomplish that. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

3 participants