[llvm-bugs] [Bug 37410] New: BPF target: segfault when a function has too many arguments

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 10 17:50:00 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37410

            Bug ID: 37410
           Summary: BPF target: segfault when a function has too many
                    arguments
           Product: clang
           Version: 3.8
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ben at extrahop.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20289
  --> https://bugs.llvm.org/attachment.cgi?id=20289&action=edit
preprocessed source

I get a segfault when I attempt to compile a function that has 6 or more
arguments.

Prior to the segfault, there's a "too many args" error emitted. I assume 6
arguments really is too many (not enough registers), 

Example:

int f(void *a, void *b, void *c, void *d, void *e, void *f) {
    return 0;
}


$ clang -target bpf -c bpfcrash.c -o bpfcrash.o
error: in function f i32 (i8*, i8*, i8*, i8*, i8*, i8*)defined with too many
args
0  libLLVM-3.8.so.1 0x00007f5d0b535d38
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 56
1  libLLVM-3.8.so.1 0x00007f5d0b533fc6 llvm::sys::RunSignalHandlers() + 54
2  libLLVM-3.8.so.1 0x00007f5d0b534129
3  libc.so.6        0x00007f5d0a6704b0
4  libLLVM-3.8.so.1 0x00007f5d0ba06c99
5  libLLVM-3.8.so.1 0x00007f5d0ba2de3e
llvm::SelectionDAGISel::LowerArguments(llvm::Function const&) + 4414
6  libLLVM-3.8.so.1 0x00007f5d0ba48181
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 1953
7  libLLVM-3.8.so.1 0x00007f5d0ba4967a
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 1178
8  libLLVM-3.8.so.1 0x00007f5d0b67b2a2
llvm::FPPassManager::runOnFunction(llvm::Function&) + 498
9  libLLVM-3.8.so.1 0x00007f5d0b67b63b
llvm::FPPassManager::runOnModule(llvm::Module&) + 43
10 libLLVM-3.8.so.1 0x00007f5d0b67aeef
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 783
11 clang            0x00000000006eb0d3
clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions
const&, clang::TargetOptions const&, clang::LangOptions const&,
llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::raw_pwrite_stream*)
+ 4403
12 clang            0x0000000000a165a1
13 clang            0x0000000000b36f7a clang::ParseAST(clang::Sema&, bool,
bool) + 938
14 clang            0x000000000099aa0e clang::FrontendAction::Execute() + 302
15 clang            0x0000000000970406
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 278
16 clang            0x0000000000a152b3
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1987
17 clang            0x00000000006b3528 cc1_main(llvm::ArrayRef<char const*>,
char const*, void*) + 2264
18 clang            0x00000000006affbc main + 6252
19 libc.so.6        0x00007f5d0a65b830 __libc_start_main + 240
20 clang            0x00000000006b1969 _start + 41
Stack dump:
0.      Program arguments: /usr/lib/llvm-3.8/bin/clang -cc1 -triple bpf
-emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name
bpfcrash.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -dwarf-column-info
-debugger-tuning=gdb -coverage-file /home/ben/bpfcrash.o -resource-dir
/usr/lib/llvm-3.8/bin/../lib/clang/3.8.0 -fdebug-compilation-dir /home/ben
-ferror-limit 19 -fmessage-length 348 -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -o bpfcrash.o -x c bpfcrash.c 
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'bpfcrash.c'.
4.      Running pass 'BPF DAG->DAG Pattern Instruction Selection' on function
'@f'
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)
Target: bpf
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/bpfcrash-25e2bd.c
clang: note: diagnostic msg: /tmp/bpfcrash-25e2bd.sh
clang: note: diagnostic msg: 

********************

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180511/966f8d4f/attachment.html>


More information about the llvm-bugs mailing list