karelklic / canal

Abstract interpreter for real-world application programs
https://github.com/karelklic/canal/wiki
Other
32 stars 3 forks source link

PointerTarget.cpp:146(merge) assert failed: mTarget == target.mTarget #132

Closed xbrukner closed 11 years ago

xbrukner commented 11 years ago
/home/tomas/projekty/canal/lib/PointerTarget.cpp:146(merge) assert failed: mTarget == target.mTarget
[bt]: (1) /home/tomas/projekty/canal/lib/libcanal.so : Canal::Pointer::Target::merge(Canal::Pointer::Target const&)+0x230 [0x4010718a]
[bt]: (2) /home/tomas/projekty/canal/lib/libcanal.so : Canal::Pointer::Pointer::join(Canal::Domain const&)+0x2ab [0x40102c6b]
[bt]: (3) /home/tomas/projekty/canal/lib/libcanal.so : Canal::Operations::select(llvm::SelectInst const&, Canal::State&)+0x255 [0x400fb3b9]
[bt]: (4) /home/tomas/projekty/canal/lib/libcanal.so : Canal::Operations::interpretInstruction(llvm::Instruction const&, Canal::State&)+0x2c6 [0x400f73f0]
[bt]: (5) /home/tomas/projekty/canal/lib/libcanal.so : Canal::Interpreter::Iterator::interpretInstruction()+0x3f [0x400f2fa5]
[bt]: (6) /home/tomas/projekty/canal/tool/canal : State::run()+0x2e [0x80cb1de]
[bt]: (7) /home/tomas/projekty/canal/tool/canal : CommandRun::run(std::vector<std::string, std::allocator<std::string> > const&)+0x7b [0x80c5527]
[bt]: (8) /home/tomas/projekty/canal/tool/canal : Commands::executeLine(std::string const&)+0x1c2 [0x80c62f0]
[bt]: (9) /home/tomas/projekty/canal/tool/canal : main+0x139 [0x80b487d]
[bt]: (10) /lib/i386-linux-gnu/libc.so.6 : __libc_start_main+0xf3 [0x404324d3]
[bt]: (11) /home/tomas/projekty/canal/tool/canal() [0x80b43b5]

Files: http://www.fi.muni.cz/~xbrukner/integration/nohup.c, http://www.fi.muni.cz/~xbrukner/integration/nohup.s http://www.fi.muni.cz/~xbrukner/integration/df.c, http://www.fi.muni.cz/~xbrukner/integration/df.s

xbrukner commented 11 years ago

nohup.s

%146 = load i8* %ignoring_input, align 1
%147 = trunc i8 %146 to i1
%148 = select i1 %147, i8* getelementptr inbounds ([42 x i8]* @.str21, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8]* @.str22, i32 0, i32 0)

df.s

%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %43
%42 = load i8** %2, align 4
br label %45
%44 = load i8** %1, align 4
br label %45
%46 = phi i8* [ %42, %41 ], [ %44, %43 ]
xbrukner commented 11 years ago

We thought that if any creation of variable or constant is paired with an instruction, it would create an unique distinction between these variables and constants. But we were wrong - you can create multiple constants in single instruction (as seen in code snippets above), where getelementptr and anonymous array construct create constants as parameter for another instruction. Therefore is necessary to have more detailed distinction (needed for example in PointerTarget).

As a solution we decided to use llvm::value to be paired with variable or constant, which may be an instruction (same as now), or parameter of another instruction if another instruction is executed in this instruction - which results in different values paired with created constants in code snippets above.