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 on mismatched operator/operand types, like -true #1249

Closed
pk19604014 opened this issue May 11, 2022 · 2 comments · Fixed by #1256
Closed

explorer crashes on mismatched operator/operand types, like -true #1249

pk19604014 opened this issue May 11, 2022 · 2 comments · Fixed by #1256
Assignees

Comments

@pk19604014
Copy link
Contributor

pk19604014 commented May 11, 2022

$ cat /tmp/testcase-6066848086228992.carbon
// Generated by proto_to_carbon.

package EmptyIdentifier impl;

fn EmptyIdentifier()
{
match (__Fn(-true) -> true) {}
}


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

>bazel run explorer:explorer /tmp/testcase-6066848086228992.carbon
INFO: Invocation ID: c889892b-eb50-4ba9-a09e-6bce23e8a736
INFO: Analyzed target //explorer:explorer (26 packages loaded, 763 targets configured).
INFO: Found 1 target...
Target //explorer:explorer up-to-date:
  bazel-bin/explorer/explorer
INFO: Elapsed time: 0.912s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
explorer: external/llvm-project/llvm/include/llvm/Support/Casting.h:262: typename cast_retty<X, Y>::ret_type llvm::cast(Y &) [X = Carbon::IntValue, Y = const Carbon::Value]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
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/testcase-6066848086228992.carbon
 #0 0x00005619ecc09beb 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 0x00005619ecf2241b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /proc/self/cwd/external/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:13
 #2 0x00005619ecf226bb PrintStackTraceSignalHandler(void*) /proc/self/cwd/external/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:1
 #3 0x00005619ecf1cd18 llvm::sys::RunSignalHandlers() /proc/self/cwd/external/llvm-project/llvm/lib/Support/Signals.cpp:98:18
 #4 0x00005619ecf23c6e SignalHandler(int) /proc/self/cwd/external/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #5 0x00007f13fa97d200 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12200)
 #6 0x00007f13fa6268a1 raise ./signal/../sysdeps/unix/sysv/linux/raise.c:50:1
 #7 0x00007f13fa610546 abort ./stdlib/abort.c:81:7
 #8 0x00007f13fa61042f get_sysdep_segment_value ./intl/loadmsgcat.c:509:8
 #9 0x00007f13fa61042f _nl_load_domain ./intl/loadmsgcat.c:970:34
#10 0x00007f13fa61f222 (/lib/x86_64-linux-gnu/libc.so.6+0x31222)
#11 0x00005619ecd4155f Carbon::Interpreter::EvalPrim(Carbon::Operator, std::__1::vector<Carbon::Value const*, std::__1::allocator<Carbon::Value const*> > const&, Carbon::SourceLocation) /proc/self/cwd/explorer/interpreter/interpreter.cpp:0:0
#12 0x00005619ecd54fe2 Carbon::Interpreter::StepExp() /proc/self/cwd/explorer/interpreter/interpreter.cpp:834:9
#13 0x00005619ecd671bd index /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:788:12
#14 0x00005619ecd671bd index /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:1438:59
#15 0x00005619ecd671bd __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
#16 0x00005619ecd671bd 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
#17 0x00005619ecd671bd ok /proc/self/cwd/./common/error.h:61:36
#18 0x00005619ecd671bd Carbon::Interpreter::Step() /proc/self/cwd/explorer/interpreter/interpreter.cpp:1312:7
#19 0x00005619ecd67ed5 Carbon::Interpreter::RunAllSteps(std::__1::unique_ptr<Carbon::Action, std::__1::default_delete<Carbon::Action> >) /proc/self/cwd/explorer/interpreter/interpreter.cpp:0:5
#20 0x00005619ecd6a6e0 ~unique_ptr /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/__memory/unique_ptr.h:272:19
#21 0x00005619ecd6a6e0 Carbon::InterpExp(Carbon::Expression const*, Carbon::Arena*, std::__1::optional<llvm::raw_ostream*>) /proc/self/cwd/explorer/interpreter/interpreter.cpp:1371:3
#22 0x00005619eccdddd5 index /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:788:12
#23 0x00005619eccdddd5 index /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:1438:59
#24 0x00005619eccdddd5 __holds_alternative<1UL, Carbon::Error, const Carbon::Value *> /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:1464:14
#25 0x00005619eccdddd5 holds_alternative<const Carbon::Value *, Carbon::Error, const Carbon::Value *> /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:1470:10
#26 0x00005619eccdddd5 ok /proc/self/cwd/./common/error.h:61:36
#27 0x00005619eccdddd5 Carbon::TypeChecker::TypeCheckExp(Carbon::Expression*, Carbon::ImplScope const&) /proc/self/cwd/explorer/interpreter/type_checker.cpp:1143:7
#28 0x00005619eccfa2d6 index /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:788:12
#29 0x00005619eccfa2d6 index /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:1438:59
#30 0x00005619eccfa2d6 __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
#31 0x00005619eccfa2d6 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
#32 0x00005619eccfa2d6 ok /proc/self/cwd/./common/error.h:61:36
#33 0x00005619eccfa2d6 Carbon::TypeChecker::TypeCheckStmt(Carbon::Statement*, Carbon::ImplScope const&) /proc/self/cwd/explorer/interpreter/type_checker.cpp:1480:7
#34 0x00005619eccfb555 Carbon::TypeChecker::TypeCheckStmt(Carbon::Statement*, Carbon::ImplScope const&) /proc/self/cwd/explorer/interpreter/type_checker.cpp:0:9
#35 0x00005619ecd05960 Carbon::TypeChecker::TypeCheckFunctionDeclaration(Carbon::FunctionDeclaration*, Carbon::ImplScope const&) /proc/self/cwd/explorer/interpreter/type_checker.cpp:0:5
#36 0x00005619ecd0c11a index /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:788:12
#37 0x00005619ecd0c11a index /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:1438:59
#38 0x00005619ecd0c11a __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
#39 0x00005619ecd0c11a 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
#40 0x00005619ecd0c11a ok /proc/self/cwd/./common/error.h:61:36
#41 0x00005619ecd0c11a Carbon::TypeChecker::TypeCheckDeclaration(Carbon::Declaration*, Carbon::ImplScope const&) /proc/self/cwd/explorer/interpreter/type_checker.cpp:2102:7
#42 0x00005619ecd167ca Carbon::TypeChecker::TypeCheck(Carbon::AST&) /proc/self/cwd/explorer/interpreter/type_checker.cpp:0:5
#43 0x00005619ecc915cb ~__tree /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/__tree:1791:11
#44 0x00005619ecc915cb ~set /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/set:619:5
#45 0x00005619ecc915cb ~TypeChecker /proc/self/cwd/./explorer/interpreter/type_checker.h:21:7
#46 0x00005619ecc915cb Carbon::ExecProgram(Carbon::Arena*, Carbon::AST, std::__1::optional<llvm::raw_ostream*>) /proc/self/cwd/explorer/interpreter/exec_program.cpp:46:3
#47 0x00005619ecc83d50 ~AST /proc/self/cwd/./explorer/ast/ast.h:17:8
#48 0x00005619ecc83d50 Carbon::Main(llvm::StringRef, int, char**) /proc/self/cwd/explorer/main.cpp:78:3
#49 0x00005619ecc82d5c index /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:788:12
#50 0x00005619ecc82d5c index /usr/local/google/home/pk19604014/.linuxbrew/Cellar/llvm/13.0.1_1/bin/../include/c++/v1/variant:1438:59
#51 0x00005619ecc82d5c __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
#52 0x00005619ecc82d5c 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
#53 0x00005619ecc82d5c ok /proc/self/cwd/./common/error.h:61:36
#54 0x00005619ecc82d5c Carbon::ExplorerMain(llvm::StringRef, int, char**) /proc/self/cwd/explorer/main.cpp:88:69
#55 0x00005619ecc821d1 main /proc/self/cwd/explorer/main_bin.cpp:0:10
#56 0x00007f13fa6117fd __libc_start_main ./csu/../csu/libc-start.c:332:16
#57 0x00005619ecbd0fca _start (/usr/local/google/home/pk19604014/.cache/bazel/_bazel_pk19604014/0c0c6d5ac7dde4460fd40f446af91e37/execroot/carbon/bazel-out/k8-fastbuild/bin/explorer/explorer+0x43cfca)
@pk19604014 pk19604014 self-assigned this May 11, 2022
@pk19604014
Copy link
Contributor Author

Looks like plain -true is diagnosed correctly as a type mismatch, but inside function type literal it's not.

package EmptyIdentifier impl;

fn Main() -> i32 {
var f: auto = __Fn(-true) -> true;
return 0;
}

@pk19604014
Copy link
Contributor Author

Type checker code calls InterpExp on function parameter type without first validating the parameter with TypeCheckExp, and InterExp crashes because it assumes negation has an integer type operand and it's actually a Bool

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
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
1 participant