[Lldb-commits] [lldb] r202086 - Fixed the command line LLDB so that "CTRL+C" will interrupt a running process again.

Greg Clayton gclayton at apple.com
Wed Feb 26 14:33:01 PST 2014


So I restored how things used to work prior the IOHandler changes. The main problem is that we receive a signal, the Driver.cpp has an installed "sigint_handler" to handler SIGINT, and this used to (prior to the IOHandler changed), and now again, calls:

	g_driver->GetDebugger().DispatchInputInterrupt();

Which eventually calls down into Process::Halt(). This definitely does way too much work and is doing many unsafe things that shouldn't be done in signal handlers.

What we need is a solution that does minimal work by trying to interrupt the current IOHandler (seen below as the call to "IOHandlerProcessSTDIO::Interrupt()") and then later the current IO handler needs to be able to do the actual work (calling Process::Halt()).

I will see if I can come up with something to fix this...

Greg

On Feb 24, 2014, at 5:05 PM, Ed Maste <emaste at freebsd.org> wrote:

> On 24 February 2014 17:50, Greg Clayton <gclayton at apple.com> wrote:
>> 
>> Author: gclayton
>> Date: Mon Feb 24 16:50:57 2014
>> New Revision: 202086
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=202086&view=rev
>> Log:
>> Fixed the command line LLDB so that "CTRL+C" will interrupt a running process again.
> 
> Hi Greg,
> 
> After this change LLDB dies on an assertion in the thread library for
> me when I hit ^C:
> 
> joule% bin/lldb /bin/sleep 60
> Current executable set to '/bin/sleep' (x86_64).
> (lldb) run
> Process 2607 launching
> Process 2607 stopped
> (lldb) Process 2607 launched: '/bin/sleep' (x86_64)
> <Ctrl+C>
> Fatal error 'thread was already on queue.' at line 223 in file
> /tank/emaste/src/freebsd/lib/libthr/thread/thr_cond.c (errno = 0)
> zsh: abort (core dumped)  bin/lldb /bin/sleep 60
> 
> This seems to be the same issue originally discussed in
> http://lists.cs.uiuc.edu/pipermail/lldb-dev/2013-June/001895.html .
> The backtrace looks like this:
> 
>    frame #1: 0x000000080715fff9 libc.so.7`abort + 73 at abort.c:65
>    frame #2: 0x0000000805d20fda
> libthr.so.3`_thread_exit(fname=<unavailable>, lineno=<unavailable>,
> msg=<unavailable>) + 58 at thr_exit.c:182
>    frame #3: 0x0000000805d1fdc8 libthr.so.3`cond_wait_common
> [inlined] cond_wait_user(mp=<unavailable>, abstime=<unavailable>,
> cancel=<unavailable>) + 936 at thr_cond.c:223
>    frame #4: 0x0000000805d1fd5b
> libthr.so.3`cond_wait_common(cond=<unavailable>, mutex=<unavailable>,
> abstime=<unavailable>, cancel=<unavailable>) + 827 at thr_cond.c:311
>    frame #5: 0x00000008013450b5
> liblldb.so.3.5`lldb_private::Condition::Wait(lldb_private::Mutex&,
> lldb_private::TimeValue const*, bool*) + 117
>    frame #6: 0x00000008013411e8
> liblldb.so.3.5`lldb_private::Predicate<bool>::WaitForValueEqualTo(bool,
> lldb_private::TimeValue const*, bool*) + 200
>    frame #7: 0x00000008013eb34c
> liblldb.so.3.5`lldb_private::Listener::WaitForEventsInternal(lldb_private::TimeValue
> const*, lldb_private::Broadcaster*, lldb_private::ConstString const*,
> unsigned int, unsigned int,
> std::__1::shared_ptr<lldb_private::Event>&) + 876
>    frame #8: 0x00000008013eb751
> liblldb.so.3.5`lldb_private::Listener::WaitForEvent(lldb_private::TimeValue
> const*, std::__1::shared_ptr<lldb_private::Event>&) + 81
>    frame #9: 0x00000008017c5bcf
> liblldb.so.3.5`lldb_private::Process::Halt(bool) + 783
>    frame #10: 0x00000008017def3a
> liblldb.so.3.5`IOHandlerProcessSTDIO::Interrupt() + 74
>    frame #11: 0x00000008013823d3
> liblldb.so.3.5`lldb_private::Debugger::DispatchInputInterrupt() + 115
>    frame #12: 0x00000008011d69c5
> liblldb.so.3.5`lldb::SBDebugger::DispatchInputInterrupt() + 69
>    frame #13: 0x000000000040b254 lldb`sigint_handler(int) + 68
>    frame #14: 0x0000000805d1b3da
> libthr.so.3`handle_signal(actp=<unavailable>, sig=<unavailable>,
> info=<unavailable>, ucp=<unavailable>) + 234 at thr_sig.c:240
>    frame #15: 0x0000000805d1afc2
> libthr.so.3`thr_sighandler(sig=<unavailable>, info=<unavailable>,
> _ucp=<unavailable>) + 306 at thr_sig.c:183
>    frame #16: 0x00007ffffffff003
>    frame #17: 0x0000000805d1fc7e libthr.so.3`cond_wait_common
> [inlined] cond_wait_user(mp=<unavailable>, abstime=<unavailable>,
> cancel=1) + 239 at thr_cond.c:255
>    frame #18: 0x0000000805d1fb8f
> libthr.so.3`cond_wait_common(cond=<unavailable>, mutex=<unavailable>,
> abstime=0x0000000000000000, cancel=1) + 367 at thr_cond.c:311
>    frame #19: 0x00000008013450d2
> liblldb.so.3.5`lldb_private::Condition::Wait(lldb_private::Mutex&,
> lldb_private::TimeValue const*, bool*) + 146
>    frame #20: 0x00000008013411e8
> liblldb.so.3.5`lldb_private::Predicate<bool>::WaitForValueEqualTo(bool,
> lldb_private::TimeValue const*, bool*) + 200
>    frame #21: 0x00000008013eb34c
> liblldb.so.3.5`lldb_private::Listener::WaitForEventsInternal(lldb_private::TimeValue
> const*, lldb_private::Broadcaster*, lldb_private::ConstString const*,
> unsigned int, unsigned int,
> std::__1::shared_ptr<lldb_private::Event>&) + 876
>    frame #22: 0x00000008013eb751
> liblldb.so.3.5`lldb_private::Listener::WaitForEvent(lldb_private::TimeValue
> const*, std::__1::shared_ptr<lldb_private::Event>&) + 81
>    frame #23: 0x00000008017b8acc
> liblldb.so.3.5`lldb_private::Process::WaitForEventsPrivate(lldb_private::TimeValue
> const*, std::__1::shared_ptr<lldb_private::Event>&, bool) + 188
>    frame #24: 0x00000008017c71e3
> liblldb.so.3.5`lldb_private::Process::RunPrivateStateThread() + 227
>    frame #25: 0x00000008017c6abd
> liblldb.so.3.5`lldb_private::Process::PrivateStateThread(void*) + 29
>    frame #26: 0x000000080133a25a
> liblldb.so.3.5`ThreadCreateTrampoline(void*) + 394
>    frame #27: 0x0000000805d16455
> libthr.so.3`thread_start(curthread=0x00000008086d5000) + 277 at
> thr_create.c:284




More information about the lldb-commits mailing list