[llvm-bugs] [Bug 25159] New: LLDB gets confused if evaluate expression executes function that generates signal

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 13 09:57:36 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=25159

            Bug ID: 25159
           Summary: LLDB gets confused if evaluate expression executes
                    function that generates signal
           Product: lldb
           Version: 3.7
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at lists.llvm.org
          Reporter: eugenebi at hotmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151013/73541940/attachment.html>


More information about the llvm-bugs mailing list