← 输入框|github.com|刷新
Skip to content

calling sys.exit causes a segfault #1782

Closed

Description

@dylon

Calling sys.exit with any value causes a segfault in lpython 0.13.0:

$ cat main.py
import sys
sys.exit(0)

$ lpython --show-c main.py
[1]    3803544 segmentation fault (core dumped)  lpython --show-c main.py

$ lpython --version
LPython version: 0.13.0
Platform: Linux
Default target: x86_64-unknown-linux-gnu

If I comment-out the call to sys.exit, lpython works as expected.

Activity

  1. Smit-create commented on May 12, 2023

    @Smit-create
    Collaborator

    On the current main branch:

    Internal Compiler Error: Unhandled exception
    Traceback (most recent call last):
      File "/Users/thebigbool/repos/lpython/src/bin/lpython.cpp", line 1739
        return emit_c(arg_file, runtime_library_dir, lpython_pass_manager,
      File "/Users/thebigbool/repos/lpython/src/bin/lpython.cpp", line 329
        r1 = LCompilers::LPython::python_ast_to_asr(al, lm, *ast, diagnostics, compiler_options, true, infile);
      File "/Users/thebigbool/repos/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 7009
        if (res2.ok) {
      File "/Users/thebigbool/repos/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 6960
        b.visit_Module(ast);
      File "/Users/thebigbool/repos/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 4195
        visit_stmt(*x.m_body[i]);
      File "/Users/thebigbool/repos/lpython/src/lpython/python_ast.h", line 1883
        void visit_stmt(const stmt_t &b) { visit_stmt_t(b, self()); }
      File "/Users/thebigbool/repos/lpython/src/lpython/python_ast.h", line 1773
        case stmtType::Expr: { v.visit_Expr((const Expr_t &)x); return; }
      File "/Users/thebigbool/repos/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 5911
        handle_attribute(te, at->m_attr, x.base.base.loc, elements);
      File "/Users/thebigbool/repos/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 677
        tmp = attr_handler.get_attribute(s, attr_name, al, loc, args, diag);
      File "/Users/thebigbool/repos/lpython/src/lpython/semantics/python_attribute_eval.h", line 56
        ASR::ttype_t *type = ASRUtils::expr_type(e);
      File "/Users/thebigbool/repos/lpython/src/libasr/asr_utils.h", line 110
        return ASR::expr_type0(f);
      File "/Users/thebigbool/repos/lpython/src/libasr/asr.h", line 45492
        return ASR::down_cast<ASR::Variable_t>(s)->m_type;
      File "/Users/thebigbool/repos/lpython/src/libasr/asr.h", line 41
        LCOMPILERS_ASSERT(is_a<T>(*f));
    AssertFailed: is_a<T>(*f)
    
  2. self-assigned this
    on May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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