Closed sunkin351 closed 3 years ago
Tagging subscribers to this area: @tommcdon See info in area-owners.md if you want to be subscribed.
Author: | sunkin351 |
---|---|
Assignees: | - |
Labels: | `area-Diagnostics-coreclr`, `untriaged` |
Milestone: | - |
@sunkin351 could you please share the "symbol load information" output for a module that isn't loading symbols? https://docs.microsoft.com/en-us/visualstudio/debugger/symbol-load-information-dialog-box?view=vs-2019
That will tell us where it "looked".
'dotnet.exe' (CoreCLR: clrhost): Loaded 'D:\Programming\Repos\Dotnet_Runtime\artifacts\bin\System.Text.RegularExpressions.Tests\net6.0-Debug\xunit.runner.visualstudio.dotnetcore.testadapter.dll'.
'dotnet.exe' (CoreCLR: clrhost): Loaded 'D:\Programming\Repos\Dotnet_Runtime\artifacts\bin\System.Text.RegularExpressions.Tests\net6.0-Debug\xunit.abstractions.dll'.
'dotnet.exe' (CoreCLR: clrhost): Loaded 'D:\Programming\Repos\Dotnet_Runtime\artifacts\bin\System.Text.RegularExpressions.Tests\net6.0-Debug\xunit.runner.utility.netcoreapp10.dll'.
I believe the main issue is it didn't load any for these. Anything else related to tests also didn't have symbols loaded... The BCL libraries appear to have had their symbols loaded. Looking further...
Modules window reports that these assemblies did not have any symbols loaded.
testhost.dll
Microsoft.TestPlatform.CoreUtilities.dll
Microsoft.TestPlatform.PlatformAbstractions.dll
Microsoft.TestPlatform.CrossPlatEngine.dll
Microsoft.TestPlatform.CommunicationUtilities.dll
Microsoft.VisualStudio.TestPlatform.ObjectModel.dll
Microsoft.VisualStudio.TestPlatform.Common.dll
xunit.abstractions.dll
Which file am I looking at? testhost?
@sunkin351 we rarely need to debug xunit itself. Normally what we care about are the symbols for System.*.dll (both product and tests). Did symbols load for System.Text.RegularExpressions.Tests.dll
and System.Text.RegularExpressions.dll
?
Now that I'm looking for them in the modules window......... they don't appear to even be there... they're not in the list. Would I per chance be debugging a host application? Also, I'd like to point out that I've let this run with the debugger attached for 50 minutes and nothing has happened yet.
Due to that particular detail coming to light... This may be worse than I originally suspected...
@sunkin351 did you build the libraries in debug or release configuration? (when you ran build.cmd at the root what parameters did you pass it?)
If release, then you probably need to switch off "just my code" in the visual studio options.
I compiled every managed assembly in debug config. Only the native runtime is in release.
So, slight progress on experimentation... After installing a VS extension that allows the debugging of child processes, I've gotten as far as hitting breakpoints and reading variable values... Major progress to be sure... But then everything else is still janky as hell. Attempting to step through code doesn't quite work and instead acts like Continue
would for starters... However these tests are setup, VS appears incapable of handling it right.
What solution did you open? If you open the S.T.RE.sln there should be no child processes when debugging..
@pgovind perhaps you can help - you've done this recently?
Attempting to step through code doesn't quite work and instead acts like Continue would for starters... However these tests are setup, VS appears incapable of handling it right.
Retail debugging can have this behavior due to both Roslyn C# and JIT optimizations leading to relatively few sequence points where the debugger can safely stop in the method. If the code is built in debug mode, the debugger should be loading the modules as non-optimized. This can be confirmed by looking in the modules window. If the modules are being loaded as optimized, you can you try enabling "Suppress JIT optimization on module load (Managed Only)" under Debug->Options. To further improve the experience you might want to consider setting the COMPLUS_ReadyToRun environment variable to 0 (zero). This will cause all ready-to-run library code to be JIT'd.
I believe @sunkin351 used the ./build -vs System.Text.RegularExpressions
command to open the solution.
@tommcdon FWIW, I've "debugged" the issue and concluded the following (this is all if you do "Debug Test" from VS, without the enablement of native code debugging and the use extension for child processes):
1) The debugger is being attached to the "right" process, namely dotnet.exe
from the testhost directory.
2) The parent process of the testhost is stuck waiting on test results.
3) The testhost itself is stuck as well, and it turns out it is not that easy to understand why. It hasn't yet loaded the assemblies under test (neither the test assembly itself, nor the source assembly). I've captured the dump, but VS refuses to analyze it (for managed code) because mscordi.dll
is not properly signed.
Viewing the stack of the main thread in WinDbg reveals that it is waiting on a lock (from the call to Task.Wait()
). It also reveals that the thread that looks related to the debugger has failed with a stack overflow and is waiting on a lock to log the failure in EEPolicy::HandleFatalStackOverflow
, this lock being used by some other 6 threads as well:
What's interesting is that just trying to "Debug Test" again from VS worked, but then when opening the solution again, it didn't, hanging with the same symptoms as above (the dump is night identical).
The issue should be reproducible if one follows these steps:
1) ./build clr -c Checked
2) ./build libs -c Debug -rc Checked
3) ./build libs.tests -c Debug -rc Checked
4) ./build -vs System.Text.RegularExpressions
5) Wait for the tests to be recognized and then click "Debug Test" on one of them for net6.0
If that would be of any interest, I can provide the dump.
VS refuses to analyze it (for managed code) because mscordi.dll is not properly signed.
@tommcdon can say, but I assume there are regkeys like these for that --
https://github.com/dotnet/diagnostics/blob/master/documentation/privatebuildtesting.md
Hmmm the runtime repo infra is complicated enough that it could be any number of things. A couple questions followed by 2 suggestions:
git clean -xdf
and a build -clean
before starting your build? I don't know why, but often this cleans up most of these VS issues.Suggestion 1 if you want to stick to VS: If you are up for it, can you do the following in a command line from `..path/to/repo/runtime/?
Suggestion 2 if you're ok with VSCode:
Since your libraries built fine, you should be able to follow https://github.com/dotnet/runtime/blob/master/docs/workflow/debugging/libraries/debugging-vscode.md
(I would still recommend cleaning and building coreclr in release with step 3 from Suggestion 1). The pdbs for each assembly live in runtime\artifacts\bin\testhost\net6.0-windows-Debug-x64\shared\Microsoft.NETCore.App\6.0.0
. My guess here is that VSCode will find the dlls/pdbs here and you will be able to debug.
1 other option to try is to put Debugger.Launch()
statements in the unit test and run it from the command line. Try to attach a new VS instance to see if that works?
I got the same issue on 2 different PCs:
Yesterday I cloned & built runtime completely without issue but had the same issue.
I followed every step but on 7. VS decided that it had to rebuild the solution, and failed because it was missing System.Compilers.(forgot).Unsafe.
A rebuild from VS cleared that error, but I hit the same issue.
Note that on one of my PC, VS does not enter in debug mode, on the other one it enter in debug mode but does nothing more.
Edit: VS Freeze if I try to detach the current process being debugged.
This is starting to suggest an issue with the debugger itself, or at least that's among the issues..
Can you use "dotnet build /t:test" on command line in the test folder for now... and Debugger.Launch() to debug? Does that work?
dotnet test
=> attaching to a new instance did work. (thanks :D)
dotnet test
=> attaching to the instance that has System.Memory opened shows the issue.
Basically if you attach the debugger from the instance of VS with System.Memory it fail, but I can debug it with a new instance without any issue.
So then it wasn't just me... That's comforting. Thank you guys for your support in this matter.
@tommcdon thoughts about this one?
What versions of VS are you both using.. can you try the newest?
16.8.4, latest release AFAIK.
Reproduces for me both on 16.8.4 and 16.9 P3.
VS refuses to analyze it (for managed code) because mscordi.dll is not properly signed.
@tommcdon can say, but I assume there are regkeys like these for that --
On Visual Studio 2019:
to reset it back to the original behavior:
"%DevEnvDir%vsregedit.exe" set "%VSINSTALLDIR:~0,-1%" HKLM Ad7Metrics\Engine{2E36F1D4-B23C-435d-AB41-18E608940038} ValidateFilesForMinidumps DWORD 1
00000035DE2BF7E0 00007ffe049631da ILStubClass.IL_STUB_ReversePInvoke(IntPtr, Int32, Byte, Int64, Int64, Int64, Int64) @tommcdon thoughts about this one?
@hoyosjs @jkoritzinsky This looks like it may be another manifestation of #47421
If I run dotnet test with a test containing Debugger.Launcher(), and attach with a new instance of VS, it works fine. But I cannot attach to a process that already tried to debug this code.
I am a potential contributor to the .NET BCL. I've encountered an issue trying to debug BCL tests from the VS test runner.
Description
I am unable to set breakpoints during debugging, unable to 'break all' (test will presumably continue running), unable to step through code as it will not break.
From the issues I've experienced, this problem shares similarities with issue #26732.If a breakpoint is set beforehand, VS will inform me, hovering over it, that "No symbols have been loaded for this document", even though this is the test that is being debugged from the VS test runner. I assume this is the cause of my issues. All managed assemblies are of the Debug configuration.
Edit: Attempting to find the tests assembly in the VS Modules window, I find it missing, along with the BCL library it should be testing. The test(s) never complete no matter how much time its given. Note: I'm debugging the tests for
System.Text.RegularExpressions
Configuration
System Config: Windows, x64 VS 2019 Version 4.8.04084
Trying to debug tests found in the master branch of this repository, after using the build command line tool to build everything.
Other information
I've talked with people in the discord about this, people there suspect that its not loading the debug symbols because they aren't being put in a spot that VS can find it. May or may not be fixable from the build script.I admit that this may or may not be a completely isolated issue. I'm still not able to solve it myself.