Samsung / netcoredbg

NetCoreDbg is a managed code debugger with GDB/MI, VSCode DAP and CLI interfaces for CoreCLR.
MIT License
826 stars 102 forks source link

Error: SysAllocStringLen not found #35

Closed mb720 closed 5 years ago

mb720 commented 5 years ago

Hi and thanks a lot for netcoredbg!

When trying to run a small "Hello World" program FirstVSCode, I get this output in the debug console of VS Code:

Starting: "bash" -c "/usr/bin/netcoredbg --interpreter=vscode"
Error: SysAllocStringLen not found
Exception thrown: 'System.ArgumentException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.ArgumentOutOfRangeException' in System.Private.CoreLib.dll
Exception thrown: 'System.ArgumentOutOfRangeException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.ArgumentOutOfRangeException' in System.Private.CoreLib.dll
The pipe program 'bash' exited unexpectedly with code 139.

This is my launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Launch (console)",
            "type": "coreclr",
            "request": "launch",

            "program": "${workspaceFolder}/bin/Debug/netcoreapp3.0/FirstVSCode.dll",
            "args": [],
            "cwd": "${workspaceFolder}",
            "stopAtEntry": false,
            "pipeTransport": {
                "pipeCwd": "${workspaceFolder}",
                "pipeProgram": "bash",
                "pipeArgs": ["-c"],
                "debuggerPath": "/usr/bin/netcoredbg"},

            "console": "internalConsole"
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach",
            "processId": "${command:pickProcess}"
        }
    ]
}

FirstVSCode.csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

</Project>

dotnet --version: 3.0.100

code --version:

1.39.2
6ab598523be7a800d7f3eb4d92d7ab9a66069390
x64

I can run the program fine using dotnet run.

I installed netcoredbg from AUR.

I'm on Arch Linux 5.3.6.

Is this an issue with netcoredbg, VS Code, or something else?


For completeness, here's the program:

using System;

namespace FirstVSCode
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello VS Code World!");

            for(int i = 0; i < 10; i++){
                Console.WriteLine($"The count is {i}.");
            }
        }
    }
}
a-zh commented 5 years ago

@mb720

Hello, I can reproduce this behavior on Windows. I believe, that our docs needs of more details. I think, you see this dotnet output because program file not exists.

Step for fix problem: 1) Also you should add tasks.json file:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet build ${workspaceRoot}/FirstVSCode.csproj",
            "type": "shell",
            "group": "build",
            "presentation": {
                "reveal": "silent"
            },
            "problemMatcher": "$msCompile"
        }
    ]
}

2) And add preLaunchTask and logging parameters in launch.json:

{
    "version": "0.2.0",
    "configurations": [
    {
        "name": ".NET Core Launch (console) with pipeline",
        "type": "coreclr",
        "request": "launch",
        "preLaunchTask": "build",

        "program": "${workspaceFolder}/bin/Debug/netcoreapp3.0/FirstVSCode.dll",
        "args": [],
        "cwd": "${workspaceFolder}",
        "stopAtEntry": false,
        "console": "internalConsole",
        "internalConsoleOptions": "openOnSessionStart",
        "logging": {
            "engineLogging": true
        },

        "pipeTransport": {
            "pipeCwd": "${workspaceFolder}",
            "pipeProgram": "bash",
            "pipeArgs": ["-c"],
            "debuggerPath": "/usr/bin/netcoredbg"},
    },
    {
        "name": ".NET Core Attach",
        "type": "coreclr",
        "request": "attach",
        "processId": "${command:pickProcess}"
    }
    ]
}

Please, tell me about results. And, please let me know if you waiting a some critical features from NetcoreDBG. Thanks a lot.

mb720 commented 5 years ago

Thanks a-zh!

This looks very promising, the program runs now with the configuration you posted. Here's the console output:

Starting: "bash" -c "/usr/bin/netcoredbg --interpreter=vscode"
-> (C) {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Code - OSS","adapterID":"coreclr","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us"},"type":"request","seq":1}
<- (E) {"body":{"capabilities":{"supportTerminateDebuggee":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsExceptionInfoRequest":true,"supportsFunctionBreakpoints":true}},"event":"capabilities","seq":1,"type":"event"}
<- (E) {"body":{},"event":"initialized","seq":2,"type":"event"}
-> (C) {"command":"launch","arguments":{"name":".NET Core Launch (console) with pipeline","type":"coreclr","request":"launch","preLaunchTask":"build","program":"/home/mb/dev/c_sharp/FirstVSCode/bin/Debug/netcoreapp3.0/FirstVSCode.dll","args":[],"cwd":"/home/mb/dev/c_sharp/FirstVSCode","stopAtEntry":false,"console":"internalConsole","internalConsoleOptions":"openOnSessionStart","logging":{"engineLogging":false},"pipeTransport":{"pipeCwd":"/home/mb/dev/c_sharp/FirstVSCode","pipeProgram":"bash","pipeArgs":["-c"],"debuggerPath":"/usr/bin/netcoredbg"},"__sessionId":"ee740b27-21aa-4bab-a808-28a3a1679a96"},"type":"request","seq":2}
<- (R) {"body":{},"command":"launch","request_seq":2,"seq":4,"success":true,"type":"response"}
-> (C) {"command":"setBreakpoints","arguments":{"source":{"name":"Program.cs","path":"/home/mb/dev/c_sharp/FirstVSCode/Program.cs","checksums":[{"algorithm":"SHA1","checksum":"1db860420585dc75bc7f9afd6e57fcc6dfc0cdee"},{"algorithm":"SHA256","checksum":"73485a883804589d86f57219fe10bd59b29f2b11a9794f28eb974d5501e6e8ec"},{"algorithm":"SHA1","checksum":"d3d02c2561ed29a13cb4cd57cfbc0a1b5963269a"},{"algorithm":"SHA256","checksum":"8d4f38d4ed3285ffcc14938a7d926fcebf454ca4633fb04682217a5f17858cb4"}]},"lines":[9,12],"breakpoints":[{"line":9},{"line":12}],"sourceModified":false},"type":"request","seq":3}
<- (R) {"body":{"breakpoints":[{"id":1,"line":9,"message":"","verified":false},{"id":2,"line":12,"message":"","verified":false}]},"command":"setBreakpoints","request_seq":3,"seq":5,"success":true,"type":"response"}
-> (C) {"command":"setFunctionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":4}
<- (R) {"body":{"breakpoints":[]},"command":"setFunctionBreakpoints","request_seq":4,"seq":6,"success":true,"type":"response"}
-> (C) {"command":"setExceptionBreakpoints","arguments":{"filters":["user-unhandled"]},"type":"request","seq":5}
<- (R) {"body":{"supportsExceptionOptions":false},"command":"setExceptionBreakpoints","request_seq":5,"seq":7,"success":true,"type":"response"}
-> (C) {"command":"configurationDone","type":"request","seq":6}
<- (R) {"body":{},"command":"configurationDone","request_seq":6,"seq":8,"success":true,"type":"response"}
<- (E) {"body":{"reason":"started","threadId":1040685},"event":"thread","seq":9,"type":"event"}
-> (C) {"command":"threads","type":"request","seq":7}
<- (R) {"body":{"threads":[{"id":1040685,"name":"<No name>"}]},"command":"threads","request_seq":7,"seq":10,"success":true,"type":"response"}
<- (E) {"body":{"module":{"id":"2f22993e-2191-4253-8bc4-d1a5a5b4b7f2","name":"System.Private.CoreLib.dll","path":"/opt/dotnet/shared/Microsoft.NETCore.App/3.0.0/System.Private.CoreLib.dll","symbolStatus":"Skipped loading symbols."},"reason":"new"},"event":"module","seq":11,"type":"event"}
<- (E) {"body":{"category":"stderr","output":"Error: SysAllocStringLen not found\n"},"event":"output","seq":12,"type":"event"}
Error: SysAllocStringLen not found
<- (E) {"body":{"module":{"id":"673cd8b9-65ef-4605-85f2-6eb95a57cf2a","name":"FirstVSCode.dll","path":"/home/mb/dev/c_sharp/FirstVSCode/bin/Debug/netcoreapp3.0/FirstVSCode.dll","symbolStatus":"Symbols not found."},"reason":"new"},"event":"module","seq":13,"type":"event"}
<- (E) {"body":{"module":{"id":"d1078d76-466d-4357-896c-dd8b50172af1","name":"System.Runtime.dll","path":"/opt/dotnet/shared/Microsoft.NETCore.App/3.0.0/System.Runtime.dll","symbolStatus":"Skipped loading symbols."},"reason":"new"},"event":"module","seq":14,"type":"event"}
<- (E) {"body":{"module":{"id":"66c2e256-1628-4d96-96dd-b5684555b12e","name":"System.Console.dll","path":"/opt/dotnet/shared/Microsoft.NETCore.App/3.0.0/System.Console.dll","symbolStatus":"Skipped loading symbols."},"reason":"new"},"event":"module","seq":15,"type":"event"}
-> (C) {"command":"threads","type":"request","seq":8}
<- (R) {"body":{"threads":[{"id":1040694,"name":"<No name>"},{"id":1040696,"name":"<No name>"},{"id":1040685,"name":"<No name>"}]},"command":"threads","request_seq":8,"seq":16,"success":true,"type":"response"}
<- (E) {"body":{"module":{"id":"c3823563-90e8-4577-9b63-bbf93fb21c90","name":"System.Threading.dll","path":"/opt/dotnet/shared/Microsoft.NETCore.App/3.0.0/System.Threading.dll","symbolStatus":"Skipped loading symbols."},"reason":"new"},"event":"module","seq":17,"type":"event"}
<- (E) {"body":{"module":{"id":"ad56330d-c0ed-4c8d-815c-9726ac61caae","name":"System.Runtime.Extensions.dll","path":"/opt/dotnet/shared/Microsoft.NETCore.App/3.0.0/System.Runtime.Extensions.dll","symbolStatus":"Skipped loading symbols."},"reason":"new"},"event":"module","seq":18,"type":"event"}
<- (E) {"body":{"module":{"id":"5c8a6096-c5be-466f-9d00-175d110bac8d","name":"System.Text.Encoding.Extensions.dll","path":"/opt/dotnet/shared/Microsoft.NETCore.App/3.0.0/System.Text.Encoding.Extensions.dll","symbolStatus":"Skipped loading symbols."},"reason":"new"},"event":"module","seq":19,"type":"event"}
<- (E) {"body":{"category":"console","output":"Exception thrown: 'System.ArgumentException' in System.Private.CoreLib.dll\n"},"event":"output","seq":20,"type":"event"}
Exception thrown: 'System.ArgumentException' in System.Private.CoreLib.dll
<- (E) {"body":{"category":"stdout","output":"Hello VS Code World!\n"},"event":"output","seq":21,"type":"event"}
Hello VS Code World!
<- (E) {"body":{"category":"stdout","output":"The count is 0.\n"},"event":"output","seq":22,"type":"event"}
The count is 0.
<- (E) {"body":{"category":"stdout","output":"The count is 1.\nThe count is 2.\n"},"event":"output","seq":23,"type":"event"}
The count is 1.
The count is 2.
<- (E) {"body":{"category":"stdout","output":"The count is 3.\nThe count is 4.\nThe count is 5.\n"},"event":"output","seq":24,"type":"event"}
The count is 3.
The count is 4.
The count is 5.
<- (E) {"body":{"category":"stdout","output":"The count is 6.\nThe count is 7.\nThe count is 8.\nThe count is 9.\n"},"event":"output","seq":25,"type":"event"}
The count is 6.
The count is 7.
The count is 8.
The count is 9.
<- (E) {"body":{"reason":"started","threadId":1040694},"event":"thread","seq":26,"type":"event"}
<- (E) {"body":{"exitCode":0},"event":"exited","seq":27,"type":"event"}
<- (E) {"body":{},"event":"terminated","seq":28,"type":"event"}
-> (C) {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":9}
<- (R) {"body":{},"command":"disconnect","request_seq":9,"seq":29,"success":true,"type":"response"}

You'll notice that Error: SysAllocStringLen not found and Exception thrown: 'System.ArgumentException' in System.Private.CoreLib.dll is still among the output but I'm not sure whether that's a serious issue.


There's one thing that I'm missing from the current configuration and that is debugging: I set two breakpoints in the program but they seem to be ignored when running the program with F5. Also pressing Ctrl + Shift + D for debugging doesn't seem to have an effect.

Do you know what I should change in my configuration to get breakpoints working?

a-zh commented 5 years ago

@mb720

Any Exceptions in output it very important for us. Now we have still a critical error Exception thrown: 'System.ArgumentException' in System.Private.CoreLib.dll. Lets try to enable this parameter:

"stopAtEntry": false, -> "stopAtEntry": true,.

If debugger works well than we should see stop by breakpoint before Main() in entry point.

Lets try to add debugger logging in the file:

"debuggerPath": "/usr/bin/netcoredbg"}, -> "debuggerPath": "/usr/bin/netcoredbg --log=file"},

Debugger should writes log files in /tmp/netcoredbg_*.log. Please, add the latest log file to ticket.

The current version of debugger not support .Net core 3.0.0. Please switch on 2.0.0.

<TargetFramework>netcoreapp3.0</TargetFramework> -> <TargetFramework>netcoreapp2.0</TargetFramework> ->

Let me know if this version critical for you. We have patch for this issue. Let me know if you want to rebuild NetcoreDBG. I will helps you.

kloned commented 5 years ago

I can confirm that debugger works with dotnet core 2.2 as well. In my case it's 2.2.402

a-zh commented 5 years ago

New commits are available. Commit https://github.com/Samsung/netcoredbg/commit/818b6f2e61e2b26dc3e8b333923059361f2021d9 should help solve problem for .Net core 3.0.0 and newest versions.

kloned commented 5 years ago

Have tried the debugger built from the latest sources comprising the commit mentioned by @a-zh . Unfortunately, I have the same Error: SysAllocStringLen not found for dotnet core 3.0. It still works fine with dotnet core 2.2.

a-zh commented 5 years ago

@viewizard

a-zh commented 5 years ago

@kloned

Have tried the debugger built from the latest sources comprising the commit mentioned by @a-zh . Unfortunately, I have the same Error: SysAllocStringLen not found for dotnet core 3.0. It still works fine with dotnet core 2.2.

Are you sure you correctly compiled and installed the debugger?

kloned commented 5 years ago

@a-zh I really hope that I've done something wrong. I would like to have it functional for dotnet core 3.0 too. But it seems that it doesn't work. What I have did: pulled the latest version from master. No modifications were made. Then followed the instructions from readme: built it by using CC=clang CXX=clang++ cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/../bin, installed through cmake --build . --target install. The debugger is referenced explicitly from VSCode's launch.json by its absolute path in debuggerPath (to eliminate any doubts). What I'm going to try next is to set the custom values for -DCORECLR_DIR=<path-to-coreclr> and -DDOTNET_DIR=<path-to-dotnet-sdk>. However, I don't think it will change something.

viewizard commented 5 years ago

@kloned please, check, that you are using latest sources. Error: SysAllocStringLen not found line was removed from sources in https://github.com/Samsung/netcoredbg/commit/818b6f2e61e2b26dc3e8b333923059361f2021d9#diff-90e3f94cc1f8a31b07d79569ec037be1L192

kloned commented 5 years ago

@a-zh @viewizard please ignore my previous message. Indeed, it was my mistake. Just have redone all from scratch in a clean environment. All works fine with no errors for dotnet 3.0. Thank you

a-zh commented 5 years ago

@mb720 Do you have any questions?

mb720 commented 5 years ago

Thanks for fixing this!

After updating netcoredbg using the repository in AUR, breakpoints work and the SysAllocStringLen error disappeared.

I'm using dotnet 3.0.100.