-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ISymbol.ToDisplayString throws NullReferenceException in SymbolDisplayVisitor #53943
Comments
The exception happens inside roslyn/src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplayVisitor.Types.cs Lines 303 to 307 in d124857
But there are no tuples in the reported |
Today, we had the same issue with another project and more syntax based rules: |
Also seen in 5.0.301 on both windows dotnet command line builds and linux. |
@jaredpar is there any ETA for a fix on this? - at the moment its causing about 50% of builds to fail for us on .net 5.0.301 - we might have to try downgrading to an earlier version of .net but then we won't have any of the security fixes |
@credfeto Thanks for the ping. Let me take a look and get back to you tomorrow. |
@credfeto @pavel-mikula-sonarsource I'm not sure what you mean in the repro steps by activating/deactivating rules. Might you have a commit/branch that would be already configured to trigger the repro? Or alternatively a zip file? |
@jcouv Repo: https://github.com/funfair-tech/CoinBot I get this on here just building... note its not all the time on this repo with the same source so best to reproduce using something like @echo off
:start
dotnet clean
dotnet build --configuration=Release
if ERRORLEVEL 1 goto finish
goto start
:finish Sample Error logs (Extracted from TC)
|
Hi @jcouv, Here's ZIP reproducer of the Just run
|
The ZIP link will probably stop working next week. Here's the same content: |
Thanks for the additional info. I wasn't able to download @pavel-mikula-sonarsource's zip file yet (requested permission). |
Hi @jcouv , I just approved the sharing. Same content is in the repo link from my previous message. |
I can confirm this issue. |
I'm still stuck on repro'ing to investigate this. I'd be able to repro with @credfeto's steps (CoinBot) but a few days later it stopped repro'ing. Not sure why. Does anyone have a crash dump file? |
@jcouv I've had it happen several times today in various projects. Not yet made it fail in the coinbot project; but have just created a branch with all changes rolled back to as it was when I referenced it as an example in June. Is there an easy way to get a crashdump without having to attach to build processes every time I do a build? Its definitely happening less than it was back in June for me. |
@credfeto If you're getting crashes and you'd like those crashes to produce crash dumps, you can set a registry key that specifies the dump output folder and the number of dump files to keep. Here's some more information. |
You can reproduce it with all rules enabled, but the build will be slower. Enabling one rule means just this: |
I just reproduced it with these steps: The first 10 runs were successful, as the issue is nondeterministic. I did set up the dump via registry, but this didn't produce a dump file because it is a caught exception. It's not a crash. From the logs:
That file has version 3.11.4.37306 |
This recently started appearing more often in our CI again |
It doesn't appear that this bug was fixed. Moving to 17.9 as I don't think we have time to do it in 17.8. |
Thanks Rikki, I confirm we've seen few of these this week. |
Does anyone have a recent repro of this issue? I tried building several of the examples in the issue in a loop and none exhibitted the described crash behavior. Happy to take non-deterministic repos and just loop the build. |
https://github.com/jjonescz/RoslynIssue53943 - run |
@jjonescz ah okay I can repro with that setup. Thanks! I was roughly trying the same approach but wasn't getting the crash (ran 50+ iterations but yours crashes after ~3). Only difference I can see is the use of the 5.0.400 SDK. Now that it repros though I'm hoping I can get it to do so with the debugger attached. This investigation though makes me wonder if we need a better debug option here for the compiler. Essentially a feature flag such that we terminate the compiler process using |
@jjonescz it does appear that the important difference in our setups is the use of the 5.0.400 SDK. I can reliably get the error to happen there but when I move to any modern SDK the error stops. This morning I effectively ran your setup with a Debug compiler from main and could not reproduce the issue here. Let it run for ~50 iterations. It seems plausible then that the issue was fixed between then and now. Are there any repros using more recent SDKs that I could look at? |
@jaredpar Yes, I can also repro only with 5.0.400 SDK. There have been more recent reports (like #69945 or #53943 (comment)) but nothing I could repro locally. @pavel-mikula-sonarsource You've said you hit this regularly in CI. What SDK version are you using there? Is the CI run public or can it be reproduced locally? |
Hi @jjonescz, The last occurrence I was able to find was on the 12th of October 2023, while analyzing https://github.com/EventStore/EventStore.git commit The other occurrence I was able to find was on the same day while analyzing https://github.com/shadowsocks/shadowsocks-windows.git commit
Would .NET 5 SDK be used here too? Older CI logs were already pruned, so I can't find previous occurrences, unfortunately. We run the CI integration tests daily and it appears very randomly. |
It's hard to say what version is used without looking at a binary log or even some msbuild diagnostic data. Given that build is initiated from VS 2019 though it's not going to be anything newer than .NET 5 SDK though. |
Given there are no repros on NET 6 or later, going to assume that one of our other race condition fixes in tuples took care of this issue as well. If someone can repro this on NET 6, or even better NET 7, please let us know and we'll dig into it. |
Version Used:
6.0.100-preview.3.21202.5 in our CI
5.0.300 as reported by @runehalfdan in our repo SonarSource/sonar-dotnet#4525 (comment)
Steps to Reproduce:
This issue doesn't reproduce in a stable way. There's some nondeterminism in the build and re-running the job usually doesn't reproduce the issue as seen in our CI as well as in our user report (see link above).
eb35cbefb700b3f219439431aa489f555a27a5de
commitdotnet build /t:Rebuild /warnaserror:AD0001
Error observed:
Adding try/catch and logging the failed symbol
ToString()
andDeclaringSyntaxReferences..SyntaxTree.FilePath
produces:ToString:
OpenIddict.Abstractions.OpenIddictExceptions.ConcurrencyException
FilePath:
C:\Project\src\OpenIddict.Abstractions\OpenIddictExceptions.cs
ToString:
OpenIddict.Server.OpenIddictServerConfiguration
FilePath:
C:\Project\src\OpenIddict.Server\OpenIddictServerConfiguration.cs
ToString:
SNINativeMethodWrapper.QTypes
FilePath: - no DeclaringSyntaxReferences
Analyzer Rule source:
https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/src/SonarAnalyzer.CSharp/Rules/ReferenceEqualityCheckWhenEqualsExists.cs
In simplified version, rule registers for
RegisterCompilationStartAction
(Line 62). There it gathers all theITypeSymbol
(including nested) fromCompilation.GlobalNamespace
. Then it iterates over eachITypeSymbol
and each of it's.BaseType
and calls.Is(KnownType.System_Object)
(Line 163) that invokes.ToDisplayString()
.Expected Behavior:
ToDisplayString()
should return some string.Actual Behavior:
ToDisplayString()
throws exception.The text was updated successfully, but these errors were encountered: