Skip to content

Compiler SIGSEGV instead of a diagnostic on a stranded lpipe() after return #3728

Description

@aleksisch

The compiler segfaults instead of reporting an error when an lpipe() trailing-block statement follows a return that already consumed a trailing block.

Repro

options gen2
require daslib/lpipe

def two_blocks(a : block<() : int>; b : block<() : int>) : int {
    return invoke(a) + invoke(b)
}

def go() : int {
    return two_blocks() {
        return 1
    }
    lpipe() {
        return 2
    }
}

[export] def main() {
    print("{go()}\n")
}
$ bin/daslang lpipe_crash.das
CRASH: SIGSEGV (Segmentation fault) (signal 11)
(core dumped)

Interpreter, no flags, no JIT. Compile-time crash — the program never runs.

Expected

A diagnostic. The input is malformed: two_blocks takes two blocks, the return supplies one as a trailing block, and the lpipe() that was meant to supply the second is stranded after the return as its own statement. The correct spelling assigns first, then pipes the second block, then returns:

var r = two_blocks() {
    return 1
}
lpipe() {
    return 2
}
return r

That version compiles and runs. Only the return-first form crashes.

Affects master

Verified on a build with no local modifications. The checkout it was built from differs from origin/master only in daslib/ast_verify.das and some utils/ast-fuzz/ test files; src/, include/, modules/ and daslib/lpipe.das are byte-identical to master, and ast_verify only runs under --ast-verify, which this repro does not pass.

How it was hit

Writing an emitter change in modules/dasLLVM/daslib/llvm_jit.das, by mis-spelling the two-block build_select(...) { ... } lpipe() { ... } idiom as return build_select(...) { ... } followed by lpipe() { ... }. A crash rather than an error makes that typo needlessly expensive to find — daslang utils/lint/main.das -- <file> also dies, so the usual check gives no clue either.

Environment

Linux, clang 20.1.2, Release build.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions