<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'> Hello,<BR> <BR>I am running Linux Ubuntu 14.04 and I tried both LLDB-3.6 (installed binaries using apt-get) and LLDB-3.7 (built from sources sync'ed to trunk), the result is the same.<BR> <BR>I have a simple program (the source code is at the bottom of the message) that maps a page of memory as not accessible, installs a SIGSEGV handler that remaps this page as read-write, and then tries to read from it. So, the expected result is that program initially receives SIGSEGV but happily continues after the handler fixes the problem.<BR> <BR>The program runs as expected, both standalone and under GDB:<BR> <BR><blockquote style="margin-right: 0px;" dir="ltr"><font face="Courier New,sans-serif" size="2">$ ./mm<br>signal 11 received<br>success 777</font><BR></blockquote><blockquote style="margin-right: 0px;" dir="ltr"><font face="Courier New,sans-serif" size="2"><br>$ gdb --quiet ./mm<br>Reading symbols from ./mm...done.<br>(gdb) r<br>Starting program: /home/eugene/tmp/mm</font><BR><font face="Courier New,sans-serif" size="2">Program received signal SIGSEGV, Segmentation fault.<br>0x0000000000400acc in main () at mm.cpp:27<br>27 int x = *(int*)address;<br>(gdb) c<br>Continuing.<br>signal 11 received<br>success 777<br>[Inferior 1 (process 14155) exited normally]<br>(gdb) q</font><br><BR></blockquote>But under LLDB it spins forever on failing instruction without invoking the signal handler. Also, setting "process handle" does not have any effect at all:<BR> <BR><blockquote style="margin-right: 0px;" dir="ltr"><font face="Courier New,sans-serif" size="2">$ ~/llvm/bin/lldb ./mm<br>(lldb) target create "./mm"<br>Current executable set to './mm' (x86_64).<br>(lldb) br se -b main<br>Breakpoint 1: where = mm`main + 30 at mm.cpp:24, address = 0x0000000000400a7e<br>(lldb) pr lau<br>Process 14194 launched: './mm' (x86_64)<br>Process 14194 stopped<br>* thread #1: tid = 14194, 0x0000000000400a7e mm`main + 30 at mm.cpp:24, name = 'mm', stop reason = breakpoint 1.1<br> frame #0: 0x0000000000400a7e mm`main + 30 at mm.cpp:24<br> 21<br> 22 int main()<br> 23 {<br>-> 24 sigset(SIGSEGV, handler);<br> 25<br> 26 address = mmap(NULL, size, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);<br> 27 int x = *(int*)address;<br>(lldb) pr ha SIGSEGV -s false -p true -n false<br>NAME PASS STOP NOTIFY<br>========== ===== ===== ======<br>SIGSEGV true false false<br>(lldb) c<br>Process 14194 resuming<br>Process 14194 stopped<br>* thread #1: tid = 14194, 0x0000000000400acc mm`main + 108 at mm.cpp:27, name = 'mm', stop reason = address access protected (fault address: 0x7ffff7ff7000)<br> frame #0: 0x0000000000400acc mm`main + 108 at mm.cpp:27<br> 24 sigset(SIGSEGV, handler);<br> 25<br> 26 address = mmap(NULL, size, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);<br>-> 27 int x = *(int*)address;<br> 28 std::cout << (signaled ? "success " : "failure ") << x << "\n";<br> 29 }<br>(lldb) c<br>Process 14194 resuming<br>Process 14194 stopped<br>* thread #1: tid = 14194, 0x0000000000400acc mm`main + 108 at mm.cpp:27, name = 'mm', stop reason = address access protected (fault address: 0x7ffff7ff7000)<br> frame #0: 0x0000000000400acc mm`main + 108 at mm.cpp:27<br> 24 sigset(SIGSEGV, handler);<br> 25<br> 26 address = mmap(NULL, size, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);<br>-> 27 int x = *(int*)address;<br> 28 std::cout << (signaled ? "success " : "failure ") << x << "\n";<br> 29 }<br>(lldb) c<br>Process 14194 resuming<br>Process 14194 stopped<br>* thread #1: tid = 14194, 0x0000000000400acc mm`main + 108 at mm.cpp:27, name = 'mm', stop reason = address access protected (fault address: 0x7ffff7ff7000)<br> frame #0: 0x0000000000400acc mm`main + 108 at mm.cpp:27<br> 24 sigset(SIGSEGV, handler);<br> 25<br> 26 address = mmap(NULL, size, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);<br>-> 27 int x = *(int*)address;<br> 28 std::cout << (signaled ? "success " : "failure ") << x << "\n";<br> 29 }<br>(lldb)</font><br><BR></blockquote>So, do I miss some LLDB setting?<BR>Here is the program code:<BR> <BR><blockquote style="margin-right: 0px;" dir="ltr"><font face="Courier New,sans-serif" size="2">$ cat mm.cpp<br>#include <iostream><br>#include <sys/mman.h><br>#include <signal.h><br>#include <assert.h><br>#include <sys/types.h><br>#include <unistd.h></font><BR><font face="Courier New" size="2"></font> <BR><font face="Courier New,sans-serif" size="2">void* address;<br>size_t size = 0x1000;<br>bool signaled = false;</font><BR><font face="Courier New" size="2"></font> <BR><font face="Courier New,sans-serif" size="2">void handler(int sig)<br>{<br> std::cout << "signal " << sig << " received\n";<br> signaled = true;<br> munmap(address, size);<br> void* newaddr = mmap(address, size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_FIXED | MAP_PRIVATE, -1, 0);<br> assert(newaddr == address);<br> *(int*)newaddr = 777;<br>}</font><BR><font face="Courier New" size="2"></font> <BR><font face="Courier New,sans-serif" size="2">int main()<br>{<br> sigset(SIGSEGV, handler);</font><BR><font face="Courier New,sans-serif" size="2"> address = mmap(NULL, size, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);<br> int x = *(int*)address;<br> std::cout << (signaled ? "success " : "failure ") << x << "\n";<br>}<br>$</font><br><BR></blockquote>Thanks,<BR>Eugene<BR> <BR> <BR> </div></body>
</html>