brendangregg / bpf-perf-tools-book

Official repository for the BPF Performance Tools book
1.61k stars 284 forks source link

tcplife: ICmp Assertion abort #1

Closed brendangregg closed 4 years ago

brendangregg commented 5 years ago

This tool worked not that long ago, but now hits an Assertion:

# tcplife.bt 
bpftrace: /usr/include/llvm-7/llvm/IR/Instructions.h:1117: void llvm::ICmpInst::AssertOK(): Assertion `getOperand(0)->getType() == getOperand(1)->getType() && "Both operands to ICmp instruction are not of the same type!"' failed.
Aborted (core dumped)
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007fffef922801 in __GI_abort () at abort.c:79
#2  0x00007fffef91239a in __assert_fail_base (fmt=0x7fffefa997d8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x5555557ebbc8 "getOperand(0)->getType() == getOperand(1)->getType() && \"Both operands to ICmp instruction are not of the same type!\"", 
    file=file@entry=0x5555557eba78 "/usr/include/llvm-7/llvm/IR/Instructions.h", line=line@entry=1117, function=function@entry=0x5555557ed820 <llvm::ICmpInst::AssertOK()::__PRETTY_FUNCTION__> "void llvm::ICmpInst::AssertOK()")
    at assert.c:92
#3  0x00007fffef912412 in __GI___assert_fail (assertion=0x5555557ebbc8 "getOperand(0)->getType() == getOperand(1)->getType() && \"Both operands to ICmp instruction are not of the same type!\"", 
    file=0x5555557eba78 "/usr/include/llvm-7/llvm/IR/Instructions.h", line=1117, function=0x5555557ed820 <llvm::ICmpInst::AssertOK()::__PRETTY_FUNCTION__> "void llvm::ICmpInst::AssertOK()") at assert.c:101
#4  0x000055555578d2a6 in llvm::ICmpInst::AssertOK (this=0x5555562f1810) at /usr/include/llvm-7/llvm/IR/Instructions.h:1116
#5  0x000055555578d3a2 in llvm::ICmpInst::ICmpInst (this=0x5555562f1810, pred=llvm::CmpInst::ICMP_NE, LHS=0x555556157e10, RHS=0x55555604b8c0, NameStr=...) at /usr/include/llvm-7/llvm/IR/Instructions.h:1171
#6  0x00005555557922d1 in llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>::CreateICmp (this=0x7fffffffe618, P=llvm::CmpInst::ICMP_NE, LHS=0x555556157e10, RHS=0x55555604b8c0, Name=...)
    at /usr/include/llvm-7/llvm/IR/IRBuilder.h:1851
#7  0x00005555557924b2 in llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>::CreateICmpNE (this=0x7fffffffe618, LHS=0x555556157e10, RHS=0x55555604b8c0, Name=...) at /usr/include/llvm-7/llvm/IR/IRBuilder.h:1741
#8  0x0000555555782956 in bpftrace::ast::CodegenLLVM::createLogicalAnd (this=0x7fffffffe5f0, binop=...) at /home/bgregg/Build/bpftrace/src/ast/codegen_llvm.cpp:1480
#9  0x000055555577d09c in bpftrace::ast::CodegenLLVM::visit (this=0x7fffffffe5f0, binop=...) at /home/bgregg/Build/bpftrace/src/ast/codegen_llvm.cpp:793
#10 0x0000555555771bae in bpftrace::ast::Binop::accept (this=0x7fffe851c180, v=...) at /home/bgregg/Build/bpftrace/src/ast/ast.cpp:45
#11 0x000055555577fc19 in bpftrace::ast::CodegenLLVM::visit (this=0x7fffffffe5f0, if_block=...) at /home/bgregg/Build/bpftrace/src/ast/codegen_llvm.cpp:1159
#12 0x0000555555771de0 in bpftrace::ast::If::accept (this=0x7fffe8a35eb0, v=...) at /home/bgregg/Build/bpftrace/src/ast/ast.cpp:89
#13 0x0000555555780be4 in bpftrace::ast::CodegenLLVM::visit (this=0x7fffffffe5f0, probe=...) at /home/bgregg/Build/bpftrace/src/ast/codegen_llvm.cpp:1290
#14 0x0000555555771e48 in bpftrace::ast::Probe::accept (this=0x555556384480, v=...) at /home/bgregg/Build/bpftrace/src/ast/ast.cpp:97
#15 0x00005555557817e5 in bpftrace::ast::CodegenLLVM::visit (this=0x7fffffffe5f0, program=...) at /home/bgregg/Build/bpftrace/src/ast/codegen_llvm.cpp:1377
#16 0x0000555555771e7c in bpftrace::ast::Program::accept (this=0x7fffe8011da0, v=...) at /home/bgregg/Build/bpftrace/src/ast/ast.cpp:101
#17 0x0000555555785037 in bpftrace::ast::CodegenLLVM::compile (this=0x7fffffffe5f0, debug=<incomplete type>, out=...) at /home/bgregg/Build/bpftrace/src/ast/codegen_llvm.cpp:1678
#18 0x000055555574ccf1 in main (argc=2, argv=0x7fffffffea38) at /home/bgregg/Build/bpftrace/src/main.cpp:417
brendangregg commented 5 years ago

The (or a) problem is this test:

if (!@birth[$sk])

This, instead, works:

if (@birth[$sk] == 0)

I think the first should work as well; I can modify the script as a workaround for now.

brendangregg commented 4 years ago

Now works in the latest bpftrace (v0.9.2-153-ga104). Removed this minor workaround in the updated version 207114439b3bcbc4f21eb8f9d899f923390090ba