<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - LLDB gets confused if evaluate expression executes function that generates signal"
href="https://llvm.org/bugs/show_bug.cgi?id=25159">25159</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>LLDB gets confused if evaluate expression executes function that generates signal
</td>
</tr>
<tr>
<th>Product</th>
<td>lldb
</td>
</tr>
<tr>
<th>Version</th>
<td>3.7
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>lldb-dev@lists.llvm.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>eugenebi@hotmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Here is a simple program that spins in an infinite loop. It contains a function
which generates SIGSEGV if it ever gets called.
I launch this program under LLDB, then hit ctrl-C to break in. On the prompt I
evaluate expression which should return function value. The expression
execution generates exception, as expected. When I hit 'continue' after that,
the program starts executing, but lldb prompt is still there and accepts
commands like 'version' or 'quit'.
In my real program LLDB would execute expression on a thread which is inside
sleep() syscall and after I continue the signal is delivered to that thread.
Unfortunately I failed to create repro for that behavior.
include <stdio.h>
#include <unistd.h>
// This function intentionally causes
// access violation (SIGSEGV). Calling
// it from LLDB command prompt confuses
// LLDB state.
int cause_sig()
{
int* addr = (int*)666;
return *addr;
}
// main function
int main()
{
// infinite loop
for (int i = 0; true; ++i)
{
printf("iteration %d\n", i);
sleep(2);
}
return 0;
}
(lldb) version
lldb version 3.7.0 (... omitted ...)
(lldb) target cr a.out
Current executable set to 'a.out' (x86_64).
(lldb) r
Process 6726 launched: '/home/eugene/tmp/a.out' (x86_64)
iteration 0
iteration 1
Process 6726 stopped
* thread #1: tid = 6726, 0x00007ffff7ad5f20 libc.so.6`__GI_nanosleep + 16, name
= 'a.out', stop reason = signal SIGSTOP
frame #0: 0x00007ffff7ad5f20 libc.so.6`__GI_nanosleep + 16
libc.so.6`__GI_nanosleep:
-> 0x7ffff7ad5f20 <+16>: cmpq $-0xfff, %rax
0x7ffff7ad5f26 <+22>: jae 0x7ffff7ad5f59 ; <+73>
0x7ffff7ad5f28 <+24>: retq
libc.so.6`???:
0x7ffff7ad5f29 <+25>: subq $0x8, %rsp
(lldb) p cause_sig()
error: Execution was interrupted, reason: signal SIGSEGV: invalid address
(fault address: 0x29a).
The process has been returned to the state before expression evaluation.
(lldb) c
Process 6726 resuming
iteration 2
iteration 3
iteration 4
iteration 5
iteration 6
(lldb) ion
lldb version 3.7.0 (... omitted ...)
iteration 7
iteration 8
(lldb) c
error: Process is running. Use 'process interrupt' to pause execution.
iteration 9
(lldb) q
iteration 10
Quitting LLDB will kill one or more processes. Do you really want to proceed:
[Y/n] y
e</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>