google / xls

XLS: Accelerated HW Synthesis

Home Page:http://google.github.io/xls/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

INTERNAL error caused by incorrect code passed to DSLX interpreter

rw1nkler opened this issue · comments

Describe the bug

While writing DSLX code, I accidentally used a struct name in place of an enum name in a match expression.
This caused an INTERNAL error which should not be observed by users.

To Reproduce

  1. Run the following snipped in DSLX interpreter:
struct X {}

enum Y: u1 {
    Y0 = 0,
    Y1 = 1,
}

#[test_proc]
proc MyTestProc {
    terminator: chan<bool> out;

    init {}
    config (terminator: chan<bool> out) {
        (terminator,)
    }

    next(tok: token, state: ()) {
        let yval = Y::Y0;
        match yval {
            X::Y0 => trace_fmt!("It's Y0!"),
            X::Y1 => trace_fmt!("It's Y1!"),
        };
        send(tok, terminator, true);
    }
}

The error message:

ERROR: /home/rwinkler/projects/xls/xls/modules/zstd/BUILD:1223:17: Parsing and type checking DSLX source files of target example_dslx failed: (Exit 255): bash failed: error executing command (from target //xls/modules/zstd:example_dslx) /bin/bash -c ... (remaining 1 argument skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
E0410 16:29:16.468494       3 deduce_utils.cc:271] INTERNAL: XLS_RET_CHECK failure (xls/dslx/type_system/deduce_utils.cc:271) type_alias != nullptr
0x55c5b273c77a: xabsl::StatusBuilder::CreateStatusAndConditionallyLog()
0x55c5b0abcd29: absl::lts_20240116::StatusOr<>::StatusOr<>()
0x55c5b0abc6a4: xls::dslx::ResolveColonRefSubjectForTypeChecking()
0x55c5b0a038cd: xls::dslx::(anonymous namespace)::DeduceVisitor::HandleColonRef()
0x55c5b0dc246b: xls::dslx::ColonRef::Accept()
0x55c5b09fad2f: xls::dslx::Deduce()
0x55c5b09ca535: std::__1::__function::__func<>::operator()()
0x55c5b0abf3d8: xls::dslx::DeduceCtx::Deduce()
0x55c5b0a083c6: xls::dslx::(anonymous namespace)::DeduceVisitor::HandleMatch()
0x55c5b0dc282b: xls::dslx::Match::Accept()
0x55c5b09fad2f: xls::dslx::Deduce()
0x55c5b09ca535: std::__1::__function::__func<>::operator()()
0x55c5b0abf3d8: xls::dslx::DeduceCtx::Deduce()
0x55c5b09fe2d4: xls::dslx::(anonymous namespace)::DeduceVisitor::HandleStatement()
0x55c5b0dc3e1b: xls::dslx::Statement::Accept()
0x55c5b09fad2f: xls::dslx::Deduce()
0x55c5b09ca535: std::__1::__function::__func<>::operator()()
0x55c5b0abf3d8: xls::dslx::DeduceCtx::Deduce()
0x55c5b0a01848: xls::dslx::(anonymous namespace)::DeduceVisitor::HandleBlock()
0x55c5b0dc362b: xls::dslx::Block::Accept()
0x55c5b09fad2f: xls::dslx::Deduce()
0x55c5b09ca535: std::__1::__function::__func<>::operator()()
0x55c5b0abf3d8: xls::dslx::DeduceCtx::Deduce()
0x55c5b09fb2a2: xls::dslx::DeduceAndResolve()
0x55c5b09cb604: xls::dslx::TypecheckFunction()
0x55c5b09c7f81: xls::dslx::TypecheckModule()
0x55c5b095aa57: xls::dslx::TypecheckModule()
0x55c5b0959f4c: xls::dslx::ParseAndTypecheck()
0x55c5b094efe5: xls::dslx::ParseAndTest()
0x55c5b08f1235: main
0x7f4f31c4ad90: [unknown]

E0410 16:29:16.468624       3 command_line_utils.cc:45] Could not extract a textual position from error message: INTERNAL: XLS_RET_CHECK failure (xls/dslx/type_system/deduce_utils.cc:271) type_alias != nullptr : INVALID_ARGUMENT: Provided status is not in recognized error form: INTERNAL: XLS_RET_CHECK failure (xls/dslx/type_system/deduce_utils.cc:271) type_alias != nullptr
Error parsing and type checking DSLX source file: xls/modules/zstd/example.x
Error: INTERNAL: XLS_RET_CHECK failure (xls/dslx/type_system/deduce_utils.cc:271) type_alias != nullptr Target //xls/modules/zstd:example_dslx_test failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.227s, Critical Path: 0.02s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully
ERROR: Build failed. Not running target

Expected behavior

A more precise error message should be provided in place of INTERNAL error