Bug 21532 - When the app's standard input has been redirected, lldb does not quit after printing native stack trace
Summary: When the app's standard input has been redirected, lldb does not quit after p...
Alias: None
Product: Runtime
Classification: Mono
Component: Debugger ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Zoltan Varga
Depends on:
Reported: 2014-07-23 01:01 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2015-05-15 19:50 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Example app and lldb output (5.98 KB, text/plain)
2014-07-23 01:01 UTC, Brendan Zagaeski (Xamarin Team, assistant)

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Brendan Zagaeski (Xamarin Team, assistant) 2014-07-23 01:01:23 UTC
Created attachment 7465 [details]
Example app and lldb output

When an app is being debugged via the soft debugger and has redirected standard input, if it crashes in native code, lldb will print a native stack trace and then never quit.

This problem happens for Xamarin.Mac apps, and also console C# apps when "Run on external console" is switched OFF.

This is a follow-up to https://bugzilla.xamarin.com/show_bug.cgi?id=19732.

## Steps to reproduce (Xamarin Studio)

1. Build `test.exe` from bug #19732.

2. Launch Xamarin Studio.

3. Choose "Run -> Debug Application", and select `test.exe`.

## Steps to reproduce (sdb)

1. Build `test.exe` from bug #19732.

2. Run `sdb`, and then run "listen 57664" at the `sdb` prompt.

4. In a separate terminal, run `test.exe`, connecting it to `sdb`:
> echo "foo" | /Library/Frameworks/Mono.framework/Versions/3.6.0/bin/mono --debug --debugger-agent=transport=dt_socket,address= test.exe

5. Once the `lldb` output from the app ends, type Ctrl-C in the `sdb` window.

6. Run "kill" at the `sdb` prompt, and then "quit".

## Result
Example app output (including lldb output) is attached.

### /var/log/system.log

> 7/22/14 11:27:35.424 PM com.apple.debugserver-310.2[64033]: debugserver-310.2 for x86_64.
> 7/22/14 11:27:35.425 PM com.apple.debugserver-310.2[64033]: Got a connection, waiting for process information for launching or attaching.
> 7/22/14 11:27:35.707 PM com.apple.debugserver-310.2[64033]: Attach succeeded, ready to debug.
> 7/22/14 11:27:36.068 PM com.apple.debugserver-310.2[64033]: 1 +0.000000 sec [fa21/0303]: error: ::ptrace (request = PT_THUPDATE, pid = 0xfa1f, tid = 0x1a03, signal = -1) err = Invalid argument (0x00000016)
> 7/22/14 11:27:36.068 PM com.apple.debugserver-310.2[64033]: Exiting.

### ps ajx | grep lldb | grep Xcode

> username      66915     1 66913      0    0 S    s002    0:00.40 /Applications/Xcode.app/Contents/Developer/usr/bin/lldb --source /tmp/mono-gdb-commands.uyO9Ko

## Version Information
Xamarin Studio 5.2 (build 384)
Mono 3.6.0 ((no/f540f8a)
sdb 1.4.5316.43108 (1b62183)
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2014-07-23 01:05:02 UTC
## Xcode and Mac version information
Xcode 5.1 (5084) Build 5B130a
OS X 10.9.4
Comment 2 Brendan Zagaeski (Xamarin Team, assistant) 2014-07-23 01:31:22 UTC
Ah. Of course now I notice that the soft debugger isn't actually required.

## Simpler steps to reproduce

1. Build `test.exe` from bug #19732.

2. Run `test.exe` with redirected standard input:
echo "foo" | mono test.exe

3. After the app outputs the "(lldb) quit" line, type Ctrl-C.

`lldb` is still running after these steps.
Comment 3 Zoltan Varga 2014-07-29 18:39:09 UTC
The current lldb version is beta quality, it has a ton of problems. Until those are solved, it might be better to use the old gdb from xcode 4.
Comment 4 Zoltan Varga 2015-05-15 19:50:34 UTC
Disabled spawning lldb for the time being.