LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 19245 - LLDB commits suicide after failing launch a process twice.
Summary: LLDB commits suicide after failing launch a process twice.
Status: RESOLVED FIXED
Alias: None
Product: lldb
Classification: Unclassified
Component: All Bugs (show other bugs)
Version: unspecified
Hardware: PC Linux
: P normal
Assignee: LLDB commit list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-25 12:58 PDT by Piotr Rak
Modified: 2016-09-26 09:51 PDT (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments
WIP take on 2nd part of bug (1.50 KB, patch)
2014-03-25 17:24 PDT, Piotr Rak
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Rak 2014-03-25 12:58:47 PDT
Steps to reproduce:

# Please note printf is shell builtin here

(lldb) file printf
Current executable set to 'printf' (x86_64).
(lldb) process launch 'hello'
error: process launch failed: Child exec failed.
(lldb) process launch 'hello'
There is a running process, kill it and restart?: [Y/n] Y
zsh: killed     ./lldb

Expected result would be failing on first command 'file'

But it uncovers that there are possibly some other problems with process state tracking.

x86_64 host, linux
lldb version trunk@204667 but could reproduce it with earlier revisions.
Comment 1 Piotr Rak 2014-03-25 13:12:55 PDT
Here is backtrack from breakpoint on kill.

(gdb) bt
#0  0x00007ffff14ce670 in kill () from /usr/lib/libc.so.6
#1  0x00007ffff4ca44f3 in ProcessPOSIX::DoDestroy (this=0x79ecb0) at ProcessPOSIX.cpp:344
#2  0x00007ffff3a7f4ed in lldb_private::Process::Destroy (this=0x79ecb0) at Process.cpp:3754
#3  0x00007ffff352631d in CommandObjectProcessLaunchOrAttach::StopProcessIfNecessary (this=0x55c0c0, process=0x79ecb0, state=@0x7fffffffb4a8: lldb::eStateLaunching, result=...)
    at CommandObjectProcess.cpp:93
#4  0x00007ffff3525b80 in CommandObjectProcessLaunch::DoExecute (this=0x55c0c0, launch_args=..., result=...) at CommandObjectProcess.cpp:202
#5  0x00007ffff375e3c0 in lldb_private::CommandObjectParsed::Execute (this=0x55c0c0, args_string=0x799dc8 "-c/bin/sh -- \"hello\"", result=...) at CommandObject.cpp:1031
#6  0x00007ffff3751731 in lldb_private::CommandInterpreter::HandleCommand (this=0x564700, command_line=0x77c7c8 "run \"hello\"", lazy_add_to_history=lldb_private::eLazyBoolCalculate, 
    result=..., override_context=0x0, repeat_on_empty_command=true, no_context_switching=false) at CommandInterpreter.cpp:1858
#7  0x00007ffff3755941 in lldb_private::CommandInterpreter::IOHandlerInputComplete (this=0x564700, io_handler=..., line=...) at CommandInterpreter.cpp:2996
#8  0x00007ffff3755c37 in non-virtual thunk to lldb_private::CommandInterpreter::IOHandlerInputComplete(lldb_private::IOHandler&, std::string&) () at CommandInterpreter.cpp:3043
#9  0x00007ffff35be1e2 in lldb_private::IOHandlerEditline::Run (this=0x761bb0) at IOHandler.cpp:576
#10 0x00007ffff359c2cc in lldb_private::Debugger::ExecuteIOHanders (this=0x504ea0) at Debugger.cpp:864
#11 0x00007ffff375604b in lldb_private::CommandInterpreter::RunCommandInterpreter (this=0x564700, auto_handle_events=true, spawn_thread=false) at CommandInterpreter.cpp:3129
#12 0x00007ffff346453a in lldb::SBDebugger::RunCommandInterpreter (this=0x7fffffffe548, auto_handle_events=true, spawn_thread=false) at SBDebugger.cpp:961
#13 0x0000000000408c88 in Driver::MainLoop (this=0x7fffffffe528) at Driver.cpp:967
#14 0x00000000004090eb in main (argc=1, argv=0x7fffffffe708, envp=0x7fffffffe718) at Driver.cpp:1066
Comment 2 emaste 2014-03-25 13:16:25 PDT
On FreeBSD the 2nd process launch hangs instead of crashing
Comment 3 Piotr Rak 2014-03-25 17:24:55 PDT
Created attachment 12287 [details]
WIP take on 2nd part of bug

Ed, could you please take a look how it works on FreeBSD? It is not really well tested, but I think it is correct. My doubt is why it is not needed gdb-remote, but I don't see how else public state could be *fixed* in this codepath.
Comment 4 labath 2016-09-26 09:51:09 PDT
works now.