[lldb-dev] [Bug 34194] New: LLDB fails to evaluate expressions which include string literals when linked against libLLVM.so
via lldb-dev
lldb-dev at lists.llvm.org
Tue Aug 15 06:22:47 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=34194
Bug ID: 34194
Summary: LLDB fails to evaluate expressions which include
string literals when linked against libLLVM.so
Product: lldb
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: lldb-dev at lists.llvm.org
Reporter: tschelle at redhat.com
CC: llvm-bugs at lists.llvm.org
Created attachment 18986
--> https://bugs.llvm.org/attachment.cgi?id=18986&action=edit
Shell script to reproduce the bug.
Description of problem:
LLDB fails to evaluate expressions which include string literals if built with
-DLLVM_LINK_LLVM_DYLIB=ON.
Version-Release number of selected component (if applicable):
Reproduces with trunk (r310911)
How reproducible:
100%
Steps to Reproduce:
1.
$ cat >test.c
#include <stdio.h>
int main(void) {
return 0;
}
2. gcc -g test.c -o test
3.
$ lldb ./test
(lldb) target create "./test"
Current executable set to './test' (x86_64).
(lldb) b main
Breakpoint 1: where = test`main + 4 at test.c:4, address = 0x00000000004004f1
(lldb) r
Process 196442 launched: './test' (x86_64)
Process 196442 stopped
* thread #1, name = 'test', stop reason = breakpoint 1.1
frame #0: test`main at test.c:4
1 #include <stdio.h>
2
3 int main(void) {
-> 4 return 0;
5 }
(lldb) expr "hello"
error: Couldn't apply expression side effects : Couldn't dematerialize a result
variable: couldn't read its memory
(lldb) expr printf("hello")
error: Execution was interrupted, reason: signal SIGSEGV: invalid address
(fault address: 0x7fdbfac1e000).
The process has been returned to the state before expression evaluation.
Actual results:
(lldb) expr "hello"
error: Couldn't apply expression side effects : Couldn't dematerialize a result
variable: couldn't read its memory
(lldb) expr printf("hello")
error: Execution was interrupted, reason: signal SIGSEGV: invalid address
(fault address: 0x7fdbfac1e000).
The process has been returned to the state before expression evaluation.
Expected results:
(lldb) expr "hello"
(const char [6]) $0 = "hello"
(lldb) expr printf("hello")
Additional info:
Works fine in the static build (see expected results) but doesn't work with
-DLLVM_LINK_LLVM_DYLIB=ON active.
Attached is a shell script which builds trunk LLVM/Clang/LLDB separately and
with -DLLVM_LINK_LLVM_DYLIB=ON. Once the build is complete it also runs the
above test case.
I have spent a significant amount of time to debug this already and it looks
like some sort of memory corruption that happens early on during the evaluation
of the 'expr "hello"' command. E.g. in a release build of Clang/LLVM/LLDB and
with "log enable lldb all" you can see that the generated LLVM IR for the
expression is slightly different in the static and dynamic build. These
differences are not visible in the debug build but it seems that there's
definitely some memory corruption going on somewhere.
Also tried to run this with AddressSanitizer but didn't get any suspicious
reports.
Reproduces at least with GCC 4.8, GCC 6.3.1 and Clang 4.0.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20170815/10161cd0/attachment.html>
More information about the lldb-dev
mailing list