Skip to content

Compiler hard-crashes (stack overflow) on pathologically deep nested types #3144

@borisbat

Description

@borisbat

Summary

The compiler stack-overflows (EXCEPTION_STACK_OVERFLOW / 0xC00000FD, process exit 3) when a single type is nested deeply enough — no AOT involved, just daslang file.das. The type-walking recursion in the parse/infer path is unbounded, so a deep enough type exhausts the C++ thread stack and crashes the process instead of producing a diagnostic.

Surfaced while working the AOT entries of #3065 (the AOT-1 fix bumps the emitter stack + fails closed; this is the separate, lower-level compiler issue underneath).

Repro A — deep pointer type (simplest)

options gen2
struct Foo {
    x : int????????????????…   // ~10000 '?'
}
[export]
def main { pass }
$ daslang foo.das
CRASH: EXCEPTION_STACK_OVERFLOW (0xC00000FD)
  (stack overflow - stack trace unavailable)

(Generate with e.g. "int" + "?" * 10000 as the field type.)

Repro B — deep function/lambda nesting (the #3065 fuzzer's vehicle)

A type of the form function < function < … < lambda<…> > … > nested ~2000+ levels deep crashes compile-check the same way (daslang deepfn.dasEXCEPTION_STACK_OVERFLOW), again with no -aot.

Inconsistent handling by depth

Behavior depends on depth and shape — it is not a clean, uniform error:

Depth (function-nesting) daslang file.das
~66 compiles
~566–1066 clean error (exit 1)
~2000+ hard crash — EXCEPTION_STACK_OVERFLOW
~8000 clean error[30151]: memory exhausted

So at some depths it errors cleanly (good), at others it crashes hard (bad).

Expected

A type nested past a sane limit should produce a clean diagnostic (e.g. "type nested too deeply") and a non-zero exit, never an uncatchable stack-overflow crash. Likely fix: bound the type-recursion depth in the parse/infer type walk (and/or the type-describe paths) and emit a compile error when exceeded.

Notes

  • Pre-existing; independent of AOT. The AOT-1 fix (separate PR) bumps only the emitter context stack, so it neither causes nor masks this.
  • Repro files used during investigation: deeply-nested-pointer and deeply-nested-function .das generated as above.

Part of the #3065 fuzzer-bug cleanup (filed separately as it is a compiler-core crash, not an AOT codegen issue).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions