trailofbits / vast

VAST is an experimental compiler pipeline designed for program analysis of C and C++. It provides a tower of IRs as MLIR dialects to choose the best fit representations for a program analysis or further program abstraction.
https://trailofbits.github.io/vast/
Apache License 2.0
391 stars 23 forks source link

[Bug]: `vast-front -cc1` crashes if not given a target dialect #663

Open PappasBrent opened 2 months ago

PappasBrent commented 2 months ago

VAST version

Ubuntu clang version 18.1.8 (++20240615103753+3b5b5c1ec4a3-1~exp1~20240615223858.136) Target: x86_64-pc-linux-gnu Thread model: posix

LLVM version

18.1.8

Operating system

Ubuntu 22.04.4 LTS x86_64

Description

vast-front crashes with the following stack trace when passed the -cc1 flag without also being passed a vast-emit-mlir flag:

[VAST fatal] not implemented: frontend_action_ptr vast::cc::create_frontend_action(compiler_instance &, const vast_args &, mcontext_t &) because unsupported frontend action
PLEASE submit a bug report to https://github.com/trailofbits/vast/issues and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: ./builds/default/tools/vast-front/Debug/vast-front -cc1 test_simple.c
 #0 0x00007fd6d798d716 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-18/lib/libLLVM.so.18.1+0xd94716)
 #1 0x00007fd6d798b6d0 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-18/lib/libLLVM.so.18.1+0xd926d0)
 #2 0x00007fd6d798dddb (/usr/lib/llvm-18/lib/libLLVM.so.18.1+0xd94ddb)
 #3 0x00007fd6d667b520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x0000562c71da9a8f vast::cc::create_frontend_action(clang::CompilerInstance&, vast::cc::vast_args const&, mlir::MLIRContext&) /home/bpappas/github.com/trailofbits/vast/tools/vast-front/compiler_invocation.cpp:57:22
 #5 0x0000562c71daa163 vast::cc::execute_compiler_invocation(clang::CompilerInstance*, vast::cc::vast_args const&) /home/bpappas/github.com/trailofbits/vast/tools/vast-front/compiler_invocation.cpp:97:23
 #6 0x0000562c71dbe8b0 vast::cc::cc1(vast::cc::vast_args const&, llvm::ArrayRef<char const*>, char const*, void*) /home/bpappas/github.com/trailofbits/vast/tools/vast-front/cc1.cpp:116:23
 #7 0x0000562c71daf8e4 execute_cc1_tool(llvm::SmallVectorImpl<char const*>&) /home/bpappas/github.com/trailofbits/vast/tools/vast-front/driver.cpp:71:16
 #8 0x0000562c71daee84 main /home/bpappas/github.com/trailofbits/vast/tools/vast-front/driver.cpp:146:20
 #9 0x00007fd6d6662d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#10 0x00007fd6d6662e40 call_init ./csu/../csu/libc-start.c:128:20
#11 0x00007fd6d6662e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#12 0x0000562c71da8bb5 _start (./builds/default/tools/vast-front/Debug/vast-front+0xe49bb5)
Illegal instruction (core dumped

Steps to Reproduce

Create a file test.c with the following contents:

int main(void) { return 0; }

Run vast-front on the file like so:

vast-front -cc1 test.c