Skip to content
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

explorer crashes when continuation name is reference inside continuation body #1263

Closed
pk19604014 opened this issue May 13, 2022 · 1 comment · Fixed by #1264
Closed

explorer crashes when continuation name is reference inside continuation body #1263

pk19604014 opened this issue May 13, 2022 · 1 comment · Fixed by #1264
Assignees

Comments

@pk19604014
Copy link
Contributor

$ cat /tmp/crash.carbon
package P impl;

fn f() {
__continuation k {
__run k;
}
}

fn Main() -> i32 {
return 0;
}

$ bazel run explorer:explorer /tmp/crash.carbon
INFO: Invocation ID: eb124ad0-ab63-479c-bd25-d42e54b90369
INFO: Analyzed target //explorer:explorer (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //explorer:explorer up-to-date:
bazel-bin/explorer/explorer
INFO: Elapsed time: 0.141s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
/usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/optional:911: _LIBCPP_ASSERT 'this->has_value()' failed. optional operator* called on a disengaged value
Please report issues to https://github.com/carbon-language/carbon-lang/issues and include the crash backtrace.
Stack dump:
0. Program arguments: /usr/local/google/home/pk19604014/.cache/bazel/_bazel_pk19604014/0c0c6d5ac7dde4460fd40f446af91e37/execroot/carbon/bazel-out/k8-fastbuild/bin/explorer/explorer /tmp/crash.carbon
#0 0x0000559574d3267b backtrace /tmp/llvm-20220302-9880-1faggz0/llvm-project-13.0.1.src/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:4202:13
#1 0x000055957504f9ab llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /proc/self/cwd/external/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:13
#2 0x000055957504fc4b PrintStackTraceSignalHandler(void*) /proc/self/cwd/external/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:1
#3 0x000055957504a2a8 llvm::sys::RunSignalHandlers() /proc/self/cwd/external/llvm-project/llvm/lib/Support/Signals.cpp:98:18
#4 0x00005595750511fe SignalHandler(int) /proc/self/cwd/external/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
#5 0x00007f1abc97f200 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12200)
#6 0x00007f1abc6288a1 raise ./signal/../sysdeps/unix/sysv/linux/raise.c:50:1
#7 0x00007f1abc612546 abort ./stdlib/abort.c:81:7
#8 0x00005595751ca80f (/usr/local/google/home/pk19604014/.cache/bazel/_bazel_pk19604014/0c0c6d5ac7dde4460fd40f446af91e37/execroot/carbon/bazel-out/k8-fastbuild/bin/explorer/explorer+0x91180f)
#9 0x0000559574dd7ff2 std::__1::optional<Carbon::Value const*>::operator*() const & /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/optional:911:9
#10 0x0000559574dee94d static_type /proc/self/cwd/./explorer/ast/statement.h:341:54
#11 0x0000559574dee94d operator() /proc/self/cwd/./explorer/ast/static_scope.h:89:45
#12 0x0000559574dee94d decltype(static_castCarbon::Continuation(fp)(static_cast<Carbon::AstNode const&>(fp0))) std::__1::__invoke<Carbon::ValueNodeView::ValueNodeView<Carbon::Continuation, void>(Carbon::Continuation const*)::'lambda1'(Carbon::AstNode const&)&, Carbon::AstNode const&>(Carbon::Continuation&&, Carbon::AstNode const&) /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/type_traits:3918:1
#13 0x0000559574dee929 std::__1::__function::__alloc_func<Carbon::ValueNodeView::ValueNodeView<Carbon::Continuation, void>(Carbon::Continuation const*)::'lambda1'(Carbon::AstNode const&), std::__1::allocator<Carbon::ValueNodeView::ValueNodeView<Carbon::Continuation, void>(Carbon::Continuation const*)::'lambda1'(Carbon::AstNode const&)>, Carbon::Value const& (Carbon::AstNode const&)>::operator()(Carbon::AstNode const&) /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/__functional/function.h:171:9
#14 0x0000559574dee7ad std::__1::__function::__func<Carbon::ValueNodeView::ValueNodeView<Carbon::Continuation, void>(Carbon::Continuation const*)::'lambda1'(Carbon::AstNode const&), std::__1::allocator<Carbon::ValueNodeView::ValueNodeView<Carbon::Continuation, void>(Carbon::Continuation const*)::'lambda1'(Carbon::AstNode const&)>, Carbon::Value const& (Carbon::AstNode const&)>::operator()(Carbon::AstNode const&) /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/__functional/function.h:345:5
#15 0x0000559574e43da6 std::__1::__function::__value_func<Carbon::Value const& (Carbon::AstNode const&)>::operator()(Carbon::AstNode const&) const /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/__functional/function.h:498:9
#16 0x0000559574e18db2 Carbon::ValueNodeView::static_type() const /proc/self/cwd/./explorer/ast/static_scope.h:116:46
#17 0x0000559574e095aa Carbon::TypeChecker::TypeCheckExp(Carbon::Expression*, Carbon::ImplScope const&) /proc/self/cwd/explorer/interpreter/type_checker.cpp:977:13
#18 0x0000559574e24acd index /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:788:12
#19 0x0000559574e24acd index /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:1438:59
#20 0x0000559574e24acd __holds_alternative<1UL, Carbon::Error, Carbon::Success> /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:1464:14
#21 0x0000559574e24acd holds_alternative<Carbon::Success, Carbon::Error, Carbon::Success> /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:1470:10
#22 0x0000559574e24acd ok /proc/self/cwd/./common/error.h:61:36
#23 0x0000559574e24acd Carbon::TypeChecker::TypeCheckStmt(Carbon::Statement*, Carbon::ImplScope const&) /proc/self/cwd/explorer/interpreter/type_checker.cpp:1663:7
#24 0x0000559574e26195 Carbon::TypeChecker::TypeCheckStmt(Carbon::Statement*, Carbon::ImplScope const&) /proc/self/cwd/explorer/interpreter/type_checker.cpp:0:9
#25 0x0000559574e26771 index /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:788:12
#26 0x0000559574e26771 index /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:1438:59
#27 0x0000559574e26771 __holds_alternative<1UL, Carbon::Error, Carbon::Success> /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:1464:14
#28 0x0000559574e26771 holds_alternative<Carbon::Success, Carbon::Error, Carbon::Success> /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:1470:10
#29 0x0000559574e26771 ok /proc/self/cwd/./common/error.h:61:36
#30 0x0000559574e26771 Carbon::TypeChecker::TypeCheckStmt(Carbon::Statement*, Carbon::ImplScope const&) /proc/self/cwd/explorer/interpreter/type_checker.cpp:1657:7
#31 0x0000559574e26195 Carbon::TypeChecker::TypeCheckStmt(Carbon::Statement*, Carbon::ImplScope const&) /proc/self/cwd/explorer/interpreter/type_checker.cpp:0:9
#32 0x0000559574e311c0 Carbon::TypeChecker::TypeCheckFunctionDeclaration(Carbon::FunctionDeclaration*, Carbon::ImplScope const&) /proc/self/cwd/explorer/interpreter/type_checker.cpp:0:5
#33 0x0000559574e3797a index /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:788:12
#34 0x0000559574e3797a index /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:1438:59
#35 0x0000559574e3797a __holds_alternative<1UL, Carbon::Error, Carbon::Success> /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:1464:14
#36 0x0000559574e3797a holds_alternative<Carbon::Success, Carbon::Error, Carbon::Success> /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:1470:10
#37 0x0000559574e3797a ok /proc/self/cwd/./common/error.h:61:36
#38 0x0000559574e3797a Carbon::TypeChecker::TypeCheckDeclaration(Carbon::Declaration*, Carbon::ImplScope const&) /proc/self/cwd/explorer/interpreter/type_checker.cpp:2199:7
#39 0x0000559574e420aa Carbon::TypeChecker::TypeCheck(Carbon::AST&) /proc/self/cwd/explorer/interpreter/type_checker.cpp:0:5
#40 0x0000559574dba05b ~__tree /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/__tree:1791:11
#41 0x0000559574dba05b ~set /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/set:619:5
#42 0x0000559574dba05b ~TypeChecker /proc/self/cwd/./explorer/interpreter/type_checker.h:21:7
#43 0x0000559574dba05b Carbon::ExecProgram(Carbon::Arena*, Carbon::AST, std::__1::optionalllvm::raw_ostream*) /proc/self/cwd/explorer/interpreter/exec_program.cpp:46:3
#44 0x0000559574dac7e0 ~AST /proc/self/cwd/./explorer/ast/ast.h:17:8
#45 0x0000559574dac7e0 Carbon::Main(llvm::StringRef, int, char**) /proc/self/cwd/explorer/main.cpp:78:3
#46 0x0000559574dab7ec index /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:788:12
#47 0x0000559574dab7ec index /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:1438:59
#48 0x0000559574dab7ec __holds_alternative<1UL, Carbon::Error, Carbon::Success> /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:1464:14
#49 0x0000559574dab7ec holds_alternative<Carbon::Success, Carbon::Error, Carbon::Success> /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:1470:10
#50 0x0000559574dab7ec ok /proc/self/cwd/./common/error.h:61:36
#51 0x0000559574dab7ec Carbon::ExplorerMain(llvm::StringRef, int, char**) /proc/self/cwd/explorer/main.cpp:88:69
#52 0x0000559574daac61 main /proc/self/cwd/explorer/main_bin.cpp:0:10
#53 0x00007f1abc6137fd __libc_start_main ./csu/../csu/libc-start.c:332:16
#54 0x0000559574cf9a5a _start (/usr/local/google/home/pk19604014/.cache/bazel/_bazel_pk19604014/0c0c6d5ac7dde4460fd40f446af91e37/execroot/carbon/bazel-out/k8-fastbuild/bin/explorer/explorer+0x440a5a)

@pk19604014 pk19604014 self-assigned this May 13, 2022
@pk19604014
Copy link
Contributor Author

Similar to #1248, type checker finds the continuation node for internal name referenced via __run, and continuation type is incomplete at this point.

pk19604014 added a commit that referenced this issue May 18, 2022
…n body (#1264)

Fixes #1263

This makes the continuation behave similar to this C++ lambda construct - auto f = []() { f(); }; which doesn't compile.
zygoloid pushed a commit that referenced this issue May 26, 2022
For issues #1248, #1249, #1257, #1263
Before the samples were only recorded as fuzzer corpus files which are less 'durable'
chandlerc pushed a commit that referenced this issue Jun 28, 2022
…n body (#1264)

Fixes #1263

This makes the continuation behave similar to this C++ lambda construct - auto f = []() { f(); }; which doesn't compile.
chandlerc pushed a commit that referenced this issue Jun 28, 2022
For issues #1248, #1249, #1257, #1263
Before the samples were only recorded as fuzzer corpus files which are less 'durable'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant