dotnet / dotnet/vscode-csharp

Debugger reports incorrect target process exit code on Linux/Mac

Open
#3,084 2 comments 0 reactions 0 assignees View on GitHub
Bug Debugger OmniSharp
Dominant language
TypeScript
Stars
3.1k
Forks
737
Avg merge
18h 40m
Merged PRs (30d)
31

Description

## Issue Description ##

If my main function returns a non-zero exit code and I run the application through the launch task (I press F5), the return code of the application is incorrectly shown as 0 instead of the exit code I specified.

## Steps to Reproduce ##

1. `dotnet new console -o TestReturnCodeIssue`
2. `cd TestReturnCodeIssue/`
3. `code -r .`
4. Click yes in the notification box asking if required assets should be built or not.
5. Change the contents of `Program.cs` to:
```C#
using System;

namespace TestReturnCodeIssue
{
class Program
{
static int Main(string[] args)
{
Console.WriteLine("Hello, World!");
return 1;
}
}
}
```
6. Press F5 (or manually run the `.NET Core Launch (console)` task).

## Expected Behavior ##

The return code of the task is listed as 1.

## Actual Behavior ##

The return code is shown as 0:

Screen Shot 2019-05-24 at 4 02 22 PM

The content of my`launch.json` is the following (I didn't change anything, I just kept the default generated one):

```json
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/TestReturnCodeIssue.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
```

Just to make sure this was only a problem with the extension, I ran the dll myself from the command line using `dotnet ./bin/Debug/netcoreapp2.2/TestReturnCodeIssue.dll` and `dotnet run` as well. In both cases, `echo $?` correctly shows the return code as 1.

## Logs ##

### OmniSharp log ###
Starting OmniSharp server at 5/24/2019, 3:54:08 PM
Target: /Users/arnavborborah/workspace/csharp/TestReturnCodeIssue

OmniSharp server started with Mono 5.18.0.
Path: /Users/arnavborborah/.vscode/extensions/ms-vscode.csharp-1.19.1/.omnisharp/1.32.19/omnisharp/OmniSharp.exe
PID: 3738

[info]: OmniSharp.Stdio.Host
Starting OmniSharp on MacOS 10.14.4 (x64)
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 2 MSBuild instance(s)
1: Mono 15.0 - "/usr/local/Cellar/mono/5.18.0.268/lib/mono/msbuild/15.0/bin"
2: StandAlone 15.0 - "/Users/arnavborborah/.vscode/extensions/ms-vscode.csharp-1.19.1/.omnisharp/1.32.19/omnisharp/.msbuild/Current/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: Mono 15.0 - "/usr/local/Cellar/mono/5.18.0.268/lib/mono/msbuild/15.0/bin"
CscToolPath = /Users/arnavborborah/.vscode/extensions/ms-vscode.csharp-1.19.1/.omnisharp/1.32.19/omnisharp/.msbuild/Current/Bin/Roslyn
CscToolExe = csc.exe
[info]: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in '/Users/arnavborborah/workspace/csharp/TestReturnCodeIssue'.
[info]: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
[info]: OmniSharp.WorkspaceInitializer
Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
[info]: OmniSharp.MSBuild.ProjectSystem
No solution files found in '/Users/arnavborborah/workspace/csharp/TestReturnCodeIssue'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/Users/arnavborborah/workspace/csharp/TestReturnCodeIssue/TestReturnCodeIssue.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/Users/arnavborborah/workspace/csharp/TestReturnCodeIssue'.
[info]: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/Users/arnavborborah/workspace/csharp/TestReturnCodeIssue' on host 3718.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /Users/arnavborborah/workspace/csharp/TestReturnCodeIssue/TestReturnCodeIssue.csproj
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/Users/arnavborborah/workspace/csharp/TestReturnCodeIssue/TestReturnCodeIssue.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project '/Users/arnavborborah/workspace/csharp/TestReturnCodeIssue/TestReturnCodeIssue.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Update project: TestReturnCodeIssue
[fail]: OmniSharp.MSBuild.ProjectManager
Exception thrown while calling event sinks
System.InvalidOperationException: object_op ---> System.EntryPointNotFoundException: SystemNative_RealPath
at (wrapper managed-to-native) Interop+Sys.RealPath(string)
at System.IO.CoreFX.FileSystemWatcher+RunningInstance.Start () [0x00000] in <3a74dd46450b43d88cb955ba6a0a3337>:0
at System.IO.CoreFX.FileSystemWatcher.StartRaisingEvents () [0x00067] in <3a74dd46450b43d88cb955ba6a0a3337>:0
at System.IO.CoreFX.FileSystemWatcher.StartRaisingEventsIfNotDisposed () [0x00019] in <3a74dd46450b43d88cb955ba6a0a3337>:0
at System.IO.CoreFX.FileSystemWatcher.set_EnableRaisingEvents (System.Boolean value) [0x0001d] in <3a74dd46450b43d88cb955ba6a0a3337>:0
at (wrapper remoting-invoke-with-check) System.IO.CoreFX.FileSystemWatcher.set_EnableRaisingEvents(bool)
at System.IO.CoreFXFileSystemWatcherProxy+<>c.b__9_0 (System.IO.CoreFX.FileSystemWatcher internal_fsw, System.IO.FileSystemWatcher fsw) [0x00048] in <3a74dd46450b43d88cb955ba6a0a3337>:0
at System.IO.CoreFXFileSystemWatcherProxy.Operation (System.Action`4[T1,T2,T3,T4] map_op, System.Action`2[T1,T2] object_op, System.Object handle, System.Action`2[T1,T2] cancel_op) [0x00184] in <3a74dd46450b43d88cb955ba6a0a3337>:0
--- End of inner exception stack trace ---
at System.IO.CoreFXFileSystemWatcherProxy.Operation (System.Action`4[T1,T2,T3,T4] map_op, System.Action`2[T1,T2] object_op, System.Object handle, System.Action`2[T1,T2] cancel_op) [0x001a6] in <3a74dd46450b43d88cb955ba6a0a3337>:0
at System.IO.CoreFXFileSystemWatcherProxy.StartDispatching (System.Object handle) [0x00004] in <3a74dd46450b43d88cb955ba6a0a3337>:0
at System.IO.FileSystemWatcher.Start () [0x0001b] in <3a74dd46450b43d88cb955ba6a0a3337>:0
at System.IO.FileSystemWatcher.set_EnableRaisingEvents (System.Boolean value) [0x0003d] in <3a74dd46450b43d88cb955ba6a0a3337>:0
at (wrapper remoting-invoke-with-check) System.IO.FileSystemWatcher.set_EnableRaisingEvents(bool)
at Microsoft.AspNetCore.Razor.OmniSharpPlugin.MSBuildProjectDocumentChangeDetector.ProjectLoaded (OmniSharp.MSBuild.Notification.ProjectLoadedEventArgs loadedArgs) [0x00266] in :0
at OmniSharp.MSBuild.ProjectManager.ProcessQueue (System.Threading.CancellationToken cancellationToken) [0x00198] in :0

### C# log ###

It's empty.

## Environment information ##

**VSCode version**: 1.34.0
**C# Extension**: 1.19.1

Mono Information
OmniSharp using global mono :5.18.0
Dotnet Information
.NET Core SDK (reflecting any global.json):
Version: 2.2.104
Commit: 73f036d4ac

Runtime Environment:
OS Name: Mac OS X
OS Version: 10.14
OS Platform: Darwin
RID: osx.10.14-x64
Base Path: /usr/local/share/dotnet/sdk/2.2.104/

Host (useful for support):
Version: 2.2.2
Commit: a4fd7b2c84

.NET Core SDKs installed:
2.2.104 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download

Visual Studio Code Extensions

|Extension|Author|Version|
|---|---|---|
|better-toml|bungcip|0.3.2|
|cpptools|ms-vscode|0.23.1|
|crystal-lang|faustinoaq|0.3.14|
|csharp|ms-vscode|1.19.1|
|docomment|k--kato|0.1.7|
|dotenv|mikestead|1.0.1|
|EditorConfig|EditorConfig|0.13.0|
|gitignore|codezombiech|0.6.0|
|Ionide-fsharp|Ionide|3.38.0|
|JavaScriptSnippets|xabikos|1.7.2|
|material-icon-theme|PKief|3.7.0|
|nim|kosz78|0.6.3|
|path-intellisense|christian-kohler|1.4.2|
|prettier-vscode|esbenp|1.9.0|
|python|ms-python|2019.4.12954|
|rust|rust-lang|0.6.1|
|Theme-TomorrowKit|ms-vscode|0.1.4|
|vscode-eslint|dbaeumer|1.9.0|
|vscode-jest|Orta|2.9.2|
|vscode-lldb|vadimcn|1.2.3|
|vscode-solution-explorer|fernandoescolar|0.3.4|
|vscode-typescript-tslint-plugin|ms-vscode|1.1.0|;

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.