LLVM Pass Crashes

Hi Team,

I am writing an LLVM pass that compiles fine and opt instrumentation goes fine as well. But when I run the instrumented C-program then I get the following stack dump. My question is, how can I debug the problem in this scenario please?

// LLVM pass compiles fine and the following OPT instrumentation goes fine for basic malloc.bc program as well. Malloc.bc runs fine without any instrumentation.

opt -o a.bc -load /data/ahmad/llvm3.1/Release+Asserts/lib/mypass.so -MyPass < malloc.bc

$ lli a.bc

*** buffer overflow detected ***: lli terminated

======= Backtrace: =========

/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x37)[0x7f946b353807]

/lib/x86_64-linux-gnu/libc.so.6(+0x109700)[0x7f946b352700]

/lib/x86_64-linux-gnu/libc.so.6(+0x108b69)[0x7f946b351b69]

/lib/x86_64-linux-gnu/libc.so.6(_IO_default_xsputn+0xdd)[0x7f946b2c513d]

/lib/x86_64-linux-gnu/libc.so.6(_IO_vfprintf+0x1d42)[0x7f946b293702]

/lib/x86_64-linux-gnu/libc.so.6(__vsprintf_chk+0x94)[0x7f946b351c04]

/lib/x86_64-linux-gnu/libc.so.6(__sprintf_chk+0x7d)[0x7f946b351b4d]

/data/ahmad/llvm3.1/Release+Asserts/lib/libdatinstrument.so(initProfiler+0x23b)[0x7f946c23e70b]

[0x7f946c5db02a]

======= Memory map: ========

00400000-00f84000 r-xp 00000000 fc:00 1974479 /usr/local/bin/lli

01183000-011d6000 r–p 00b83000 fc:00 1974479 /usr/local/bin/lli

Stack dump:

  1. Program arguments: lli a.bc

Aborted (core dumped)

Thanks.

Hi Ahmad,

> I am writing an LLVM pass that compiles fine and opt instrumentation goes fine

as well. But when I run the instrumented C-program then I get the following
stack dump. My question is, how can I debug the problem in this scenario please?

// LLVM pass compiles fine and the following OPT instrumentation goes fine for
basic malloc.bc program as well. Malloc.bc runs fine without any instrumentation.

opt -o a.bc -load /data/ahmad/llvm3.1/Release+Asserts/lib/mypass.so -MyPass <
malloc.bc

$ lli a.bc

*** buffer overflow detected ***: lli terminated

this looks like a bug in your IR. I suggest you compile and link to a normal
program using llc + assembler + linker, rather than running under lli, and debug
in the classical way, eg using valgrind. You can also run lli in a debugger, or
under valgrind.

Ciao, Duncan.