dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.88k stars 676 forks source link

Process terminated through Debugger inspecting property under Linux #3723

Open syntacs opened 4 years ago

syntacs commented 4 years ago

Issue Type: Bug

The included Program has a class property who's getter accesses a postgres database. Steps:

using System.Data;
using System;
using Npgsql;

namespace crash_demo
{
    class Program
    {
        static void Main(string[] args)
        {
            CrashDemo demo = new CrashDemo();
            Console.WriteLine("ClientIs is " + demo.ClientId);
        }

        public class CrashDemo
        {
            public string ClientId
            {
                get
                {
                    string clientId = string.Empty;
                    using (IDbConnection connection = GetConnection())
                    {
                        IDbCommand dbCommand = connection.CreateCommand();
                        dbCommand.CommandType = CommandType.Text;

                        dbCommand.CommandText = @"select client_id from clients where kdnr = '123456'";
                        IDataReader reader = dbCommand.ExecuteReader();

                        if (reader.Read())
                        {
                            clientId = (string)reader["client_id"];
                        }
                        reader.Dispose();
                        return clientId;
                    }
                }
            }
            IDbConnection GetConnection()
            {
                IDbConnection connection = new NpgsqlConnection();
                connection.ConnectionString = "Host=127.0.0.1;Username=stocks;Database=stocks";
                connection.Open();
                return connection;
            }
        }
    }
}

VS Code version: Code 1.43.2 (0ba0ca52957102ca3527cf479571617f0de6ed50, 2020-03-24T07:52:11.516Z) OS version: Linux x64 5.5.10-200.fc31.x86_64

System Info |Item|Value| |---|---| |CPUs|Intel Core Processor (Skylake, IBRS) (3 x 2207)| |GPU Status|2d_canvas: unavailable_software
flash_3d: unavailable_off
flash_stage3d: unavailable_off
flash_stage3d_baseline: unavailable_off
gpu_compositing: unavailable_off
multiple_raster_threads: disabled_off
oop_rasterization: unavailable_off
protected_video_decode: unavailable_off
rasterization: unavailable_off
skia_renderer: disabled_off_ok
video_decode: unavailable_off
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled_readback
webgl2: unavailable_off| |Load (avg)|1, 1, 1| |Memory (System)|7.77GB (3.30GB free)| |Process Argv|--no-sandbox| |Screen Reader|no| |VM|0%|
Extensions (8) Extension|Author (truncated)|Version ---|---|--- vscode-css-formatter|aes|1.0.1 vs-code-xml-format|fab|0.1.5 vscode-firefox-debug|fir|2.7.1 auto-using|Fud|0.7.15 csharp|ms-|1.21.16 mono-debug|ms-|0.15.8 debugger-for-chrome|msj|4.12.6 vscode-gitignore-generator|pio|1.0.1
filipw commented 4 years ago

Debugger is part of the VS Code extension, not omnisharp server, moving to the appropriate repo.

syntacs commented 4 years ago

Here's some more detailed information: I ran ./vsdbg-ui --server --consoleLogging and pointed to this dbg instance in launch.json.

Scenario1 (already known but with new detail and dbg server log) :

Scenario2 (modified program, modified test):

The modified main() for scenario2:

 static void Main(string[] args)
        {
            CrashDemo demoClass = new CrashDemo();
            Console.WriteLine("ClientIs is " + demoClass.ClientId);
            ResourceReader reader = new ResourceReader("");
        }

scenario1.log scenario2.log