dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.71k stars 3.98k forks source link

C# Scripting: crash dump without symbols in runtime-compiled code #31030

Open pongba opened 5 years ago

pongba commented 5 years ago

We load a bunch of extension scripts .csx at runtime like this:

            var script = CSharpScript.Create<int>(content, globalsType: typeof(Interfaces.IGlobals),
                options: ScriptOptions
                .Default
                .WithFilePath(@"C:\path\to\the\script.csx")
                .WithEmitDebugInformation(true)
                .WithFileEncoding(Encoding.UTF8));

Now if say stack overflow happens inside the script.csx, I would like to be able to examine the minidump and at least tell which line inside the .csx is causing the overflow.

But unfortunately since the .csx is loaded at runtime and therefore its PDB is in-memory (not on disk), it seems that all I have is cryptic stack frame like this:

           [Frames below may be incorrect and/or missing, no binaries loaded for ℛ*6087ff7e-7cbd-41b8-885b-00bbec343cec#1-0.dll]   
           [Frames below may be incorrect and/or missing, no binaries loaded for ℛ*6087ff7e-7cbd-41b8-885b-00bbec343cec#1-0.dll]   
           [Frames below may be incorrect and/or missing, no binaries loaded for ℛ*6087ff7e-7cbd-41b8-885b-00bbec343cec#1-0.dll]   

Is there any way to workaround this? Without source line info we're essentially blind..

Azure functions uses .csx for extension, I wonder how they're solving this issue..

jinujoseph commented 5 years ago

cc @tmat

pongba commented 5 years ago

I would also add that for on-disk assemblies, even if the PDB is not present, the stack frame would still show the function name (although no file/source line info). function name is some times enough for diagnosing issues. But unfortunately for in memory PDB the function name is not present either.

tmat commented 5 years ago

Does it occur when running on .NET Core or .NET Framework? Which version?

pongba commented 5 years ago

@tmat .NET Framework 4.6+