You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot print exception string because Exception.ToString() failed #6299
This occurred on an Ubuntu CI job while running Base02d_seq_ser. The job appears to have been kicked off for this PR but I don't have any reason to believe it's related to the changes in that PR.
As for the first dump (I haven't looked at the other yet), I can see that the formatting of the stack trace has failed due to the null reference exception:
(lldb) pe
Exception object: 00007f74a0017728
Exception type: System.NullReferenceException
Message: Object reference not set to an instance of an object.
InnerException: <none>
StackTrace (generated):
SP IP Function
00007FFFF222B6D0 00007F78F00434D5 System.Private.CoreLib.dll!System.Text.StringBuilder.AppendFormatHelper(System.IFormatProvider, System.String, System.ParamsArray)+0x905
00007FFFF222B760 00007F78F02CBF46 System.Private.CoreLib.dll!System.Diagnostics.StackTrace.ToString(TraceFormat)+0x266
00007FFFF222B890 00007F78F0055A88 System.Private.CoreLib.dll!System.Exception.GetStackTrace(Boolean)+0x48
00007FFFF222B8B0 00007F78F0055919 System.Private.CoreLib.dll!System.Exception.ToString(Boolean, Boolean)+0x189
00007FFFF222B8F0 00007F78F0054DD8 System.Private.CoreLib.dll!System.Exception.InternalToString()+0x68
StackTraceString: <none>
HResult: 80004003
Disassembling code around the failure point shows something strange:
00007f78f00434c6 488b7db0 mov rdi, qword ptr [rbp - 0x50]
00007f78f00434ca 4885ff test rdi, rdi
00007f78f00434cd 0f84aa000000 je 0x7f78f004357d
00007f78f00434d3 33ff xor edi, edi
>>> 00007f78f00434d5 488b07 mov rax, qword ptr [rdi]
See the xor edi, edi? That means that the RDI would always be zero there! The function is quite long, but trying to match the source and the diassembly, it looks like the test rdi, rdi is the else if (arg != null) below:
I was curious about this so I dumped the disassembly for System.Private.CoreLib.dll!System.Text.StringBuilder.AppendFormatHelper from an older dump (from some unrelated run last week) and noticed that it's different (excerpts below):
I'm looking at this, while in parallel attempting to run the failing arm tests from #6283 on the emulator. Using the corerun from the 2nd dump location above, with a version of the test built locally, I would expect the code generated to be the same, since it is exactly the same jit.
I am unable to repro this with either test case. What's even stranger than the fact that the "this" pointer is being set to zero is that just above, it has been tested against zero. It's almost as if assertion prop has gotten it exactly backward (i.e. propagating null to this block instead of non-null), or that value numbering is incorrectly propagating the results of the IsInstanceOf call. If my dotnet/coreclr#6227 PR is indeed responsible for the arm failures in #6283 (which I'm still working on attempting to repro), it would be very surprising if it is the same issue as this, since this deals with object refs and my PR should affect only structs (unless, of course, there's some interaction that I haven't been able to see). @dotnet/jit-contrib - can anyone else think of something in the JIT that might determine that a ref's value is zero?
So presumably confirmed that this is indeed not due to dotnet/coreclr#6021 since that was backed out. The symptom became basically 100% repro on ARM after dotnet/coreclr#6021, though, so perhaps it would be better to investigate the problem there in case both the ARM failure and the x64 failure happen to be the same issue.
@papaslavik has identified the root cause of at least one of the arm failures (#6459) that seems to be similar to this. We have both been looking into potential solutions. Of course, there's no guarantee that it is the same root cause as this, but since it is an issue of using uninitialized data in assertion prop (and the bad code generated here has the appearance of being bad assertion prop), it could very well be.
@adityamandaleeka - I just merged a PR (#6484) that fixes a problem with assertion prop using uninitialized data. I am hoping these intermittent failures are addressed by that as well. Please let me know if you encounter more of these failures.
@reinux, do you happen to still have the details of your issue? Yours seems to be related to F#, and I encounter it now as well, see this PR: dotnet/fsharp#9549 (specifically here: dotnet/fsharp#9549 (comment)). Or did you report it elsewhere? I've difficulty pinning it down...
Okay, it's happening again, this time using the IdentityModel package.
.NET Core 3.1, only depending on IdentityModel 4.3.0, Newtonsoft.Json 12.0.3 and System.Text.Encodings.Web 4.7.1.
The entirety of code:
open System.Net.Http
open IdentityModel.Client
let client = new HttpClient()
let disco =
client.GetDiscoveryDocumentAsync("http://localhost:7000")
|> Async.AwaitTask |> Async.RunSynchronously
[<EntryPoint>]
let main argv =
0 // return an integer exit code
@reinux, You happen to run into similar issues while I'm also working on it. I suspect that the reason this error is thrown is caused by a combination of two things:
While compiling, the references are fine, but when running or inspecting the code, they are not. This leads to types not being found. Normally this would give a "reference not found error"
When an exception is raised, this exception may not have ToString() or Message overridden. If that isn't overridden, the base Exception class calls GetClassName(), which in turn calls GetType(). I suspect that this throws, which then in turn leads to the very confusing error "Cannot print exception string because Exception.ToString() failed".
What complicates matters is that with F# there can be difference between inlined and not-inlined functions. This means that while compiling, the reference is needed, but when running, it isn't. Furthermore, the inlining itself can lead to a dependency that you wouldn't have had when the inlining didn't happen (this has to do with optimizations). Whether that's the case here remains to be seen.
I have yet to confirm this analysis. But if true, I think that a solution shouldn't be too hard, I hope.
@reinux please open a new issue. Also more info: .NET version it's running on, and what happens under a debugger.
We should probably do what @danmosemsft suggests here. As this original issue is closed. Could you do the honors of creating an issue for F# with your repro here: https://github.com/dotnet/fsharp/issues?
Running it in the VS debugger, I get this exception, which is really bonkers:
System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for '<StartupCode$TestClient2>.$Program' threw an exception.
Source=TestClient2
StackTrace:
at Program.main(String[] argv) in C:\Users\rei\source\repos\AoiFrontDesk\TestClient2\Program.fs:line 12
Inner Exception 1:
FileNotFoundException: Could not load file or assembly 'FSharp.Core, Version=4.7.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
No, I'm working on optimizations for FSharp.Core.dll and it runs certain tests that, after my optimizations, exhibited this error. All points to references, indeed. But I don't think it is isolated with Paket, at least not for me.
But whatever the repro, the error as shown here should simply not be raised. I mean, the TypeInitializationException is kind of "normal" and can be solved (it indicates a bug by itself), but the "Cannot print exception string" certainly shouldn't happen, unless it was caused by deliberately evil user code.
It seems to be because this version of paket (which I just realized is 5 months old now...) is removing FSharp.Core.dll. So my theory currently is this:
There's a call being made to something in FSharp.Core either before or inside Exception.ToString()
Either VS debugger doesn't use Exception.ToString() so it shows TypeInitializationException instead, or it tries to call FSharp.Core.dll for some other purpose prior, and notices it's missing
dotnet run, on the other hand, just shows this "not-even-an-exception error message" because they didn't expect top-level exception handling to depend in any way on a (potentially missing) library.
I have a really strong hunch that updating paket will fix this problem for me, and so it's probably not going to be reproducible in this way for other people with the steps I used.
Just wanted to run it by you before I do, in case you can think of a good way to express this problem to whomever might be in a position to improve it, which is kind of starting to look like more the dotnet runtime people if anything.
Looks like your reference to the Paket issue, and your analysis, all point in the same direction: a missing dll, specifically FSharp.Core.
I still feel it shouldn't throw that error "cannot print etc", even though we know the cause.
The reason you see the type load exception, is because when debugging, you see the first chance exceptions. If there's no debugger attached, it goes to the exception handler (which defaults to printing the error, which it can't).
The reason you see the type load exception, is because when debugging, you see the first chance exceptions.
Oh right, I forgot about that.
Edit: Side note: The problem with the GetDiscoveryDocumentAsync extension method not being found by FSI seems to be unrelated. Referencing the extension method by its actual name seems to work:
Tried a few experiments with async extension methods with default parameters and such, but I couldn't nail down exactly why this is happening with this particular method.
ghost locked as resolved and limited conversation to collaborators on Dec 30, 2020
Activity
adityamandaleeka commentedon Jul 11, 2016
Another example of this: http://dotnet-ci.cloudapp.net/job/dotnet_coreclr/job/master/job/checked_ubuntu_tst_prtest/3179
This time in Loader/classloader/generics/Instantiation/Negative/abstract08
Dump and binaries: http://dotnetrp.azurewebsites.net/dumpling/download/1507
janvorli commentedon Jul 11, 2016
As for the first dump (I haven't looked at the other yet), I can see that the formatting of the stack trace has failed due to the null reference exception:
Disassembling code around the failure point shows something strange:
See the xor edi, edi? That means that the RDI would always be zero there! The function is quite long, but trying to match the source and the diassembly, it looks like the test rdi, rdi is the
else if (arg != null)below:adityamandaleeka commentedon Jul 11, 2016
The second dump has exactly the same issue. I wonder if this is related to any recent JIT changes.
adityamandaleeka commentedon Jul 12, 2016
I was curious about this so I dumped the disassembly for
System.Private.CoreLib.dll!System.Text.StringBuilder.AppendFormatHelperfrom an older dump (from some unrelated run last week) and noticed that it's different (excerpts below):OLDER
NEWER
parjong commentedon Jul 12, 2016
Is it related with #6283? The error log looks very similar.
CarolEidt commentedon Jul 12, 2016
I'm looking at this, while in parallel attempting to run the failing arm tests from #6283 on the emulator. Using the corerun from the 2nd dump location above, with a version of the test built locally, I would expect the code generated to be the same, since it is exactly the same jit.
CarolEidt commentedon Jul 13, 2016
I am unable to repro this with either test case. What's even stranger than the fact that the "this" pointer is being set to zero is that just above, it has been tested against zero. It's almost as if assertion prop has gotten it exactly backward (i.e. propagating null to this block instead of non-null), or that value numbering is incorrectly propagating the results of the IsInstanceOf call. If my dotnet/coreclr#6227 PR is indeed responsible for the arm failures in #6283 (which I'm still working on attempting to repro), it would be very surprising if it is the same issue as this, since this deals with object refs and my PR should affect only structs (unless, of course, there's some interaction that I haven't been able to see). @dotnet/jit-contrib - can anyone else think of something in the JIT that might determine that a ref's value is zero?
swgillespie commentedon Jul 15, 2016
Here's another CI failure that looks like this, but on ARM: http://dotnet-ci.cloudapp.net/job/dotnet_coreclr/job/master/job/arm_emulator_cross_release_ubuntu_prtest/522/console
adityamandaleeka commentedon Jul 15, 2016
This just repro'd again on the Ubuntu job for PR dotnet/coreclr#6297
adityamandaleeka commentedon Jul 27, 2016
Here are a few more dumps for occurrences of this issue in CoreCLR CI runs:
http://dotnetrp.azurewebsites.net/dumpling/download/1579
http://dotnetrp.azurewebsites.net/dumpling/download/1580
http://dotnetrp.azurewebsites.net/dumpling/download/1581
http://dotnetrp.azurewebsites.net/dumpling/download/1582
http://dotnetrp.azurewebsites.net/dumpling/download/1598
http://dotnetrp.azurewebsites.net/dumpling/download/1601
http://dotnetrp.azurewebsites.net/dumpling/download/1604
http://dotnetrp.azurewebsites.net/dumpling/download/1606
adityamandaleeka commentedon Jul 27, 2016
It just happened again: http://dotnet-ci.cloudapp.net/job/dotnet_coreclr/job/master/job/checked_ubuntu_tst_prtest/3577/consoleFull#2096352037c7af6a29-b465-404a-b249-90a3911e4354
http://dotnetrp.azurewebsites.net/dumpling/download/1610
adityamandaleeka commentedon Jul 27, 2016
And another: http://dotnet-ci.cloudapp.net/job/dotnet_coreclr/job/master/job/jitstress/job/x64_checked_ubuntu_jitstressregs0x10_tst/33/
http://dotnetrp.azurewebsites.net/dumpling/download/1611
RussKeldorph commentedon Jul 27, 2016
So presumably confirmed that this is indeed not due to dotnet/coreclr#6021 since that was backed out. The symptom became basically 100% repro on ARM after dotnet/coreclr#6021, though, so perhaps it would be better to investigate the problem there in case both the ARM failure and the x64 failure happen to be the same issue.
CarolEidt commentedon Jul 27, 2016
@papaslavik has identified the root cause of at least one of the arm failures (#6459) that seems to be similar to this. We have both been looking into potential solutions. Of course, there's no guarantee that it is the same root cause as this, but since it is an issue of using uninitialized data in assertion prop (and the bad code generated here has the appearance of being bad assertion prop), it could very well be.
CarolEidt commentedon Jul 27, 2016
@adityamandaleeka - I just merged a PR (#6484) that fixes a problem with assertion prop using uninitialized data. I am hoping these intermittent failures are addressed by that as well. Please let me know if you encounter more of these failures.
8 remaining items
abelbraaksma commentedon Jun 24, 2020
@reinux, do you happen to still have the details of your issue? Yours seems to be related to F#, and I encounter it now as well, see this PR: dotnet/fsharp#9549 (specifically here: dotnet/fsharp#9549 (comment)). Or did you report it elsewhere? I've difficulty pinning it down...
reinux commentedon Jun 24, 2020
@abelbraaksma @danmosemsft Nuts. I totally missed this, and now that I've tried it again, I can't reproduce the problem.
Really sorry about that.
As far as I remember, though, that was all there was to it. No other changes to the project, no other errors.
I wish I could be of more help.
abelbraaksma commentedon Jun 25, 2020
@reinux, no worries, these things happen ;). Anyway, I do have a repro now, I'll report it separately if I can isolate it.
reinux commentedon Jul 4, 2020
Okay, it's happening again, this time using the IdentityModel package.
.NET Core 3.1, only depending on
IdentityModel 4.3.0,Newtonsoft.Json 12.0.3andSystem.Text.Encodings.Web 4.7.1.The entirety of code:
reinux commentedon Jul 4, 2020
I also noticed something strange:
Trying to use the
GetDiscoveryDocumentAsyncextension method from IdentityModel.Client, Visual Studio recognizes it, but FSI doesn't see it at all.Normally, if I'm missing some references or something, VS would know. So I think that's probably what the error was trying to tell me.
Would you happen to know if there might be a workaround?
abelbraaksma commentedon Jul 4, 2020
@reinux, You happen to run into similar issues while I'm also working on it. I suspect that the reason this error is thrown is caused by a combination of two things:
ToString()orMessageoverridden. If that isn't overridden, the baseExceptionclass callsGetClassName(), which in turn callsGetType(). I suspect that this throws, which then in turn leads to the very confusing error "Cannot print exception string because Exception.ToString() failed".What complicates matters is that with F# there can be difference between inlined and not-inlined functions. This means that while compiling, the reference is needed, but when running, it isn't. Furthermore, the inlining itself can lead to a dependency that you wouldn't have had when the inlining didn't happen (this has to do with optimizations). Whether that's the case here remains to be seen.
I have yet to confirm this analysis. But if true, I think that a solution shouldn't be too hard, I hope.
abelbraaksma commentedon Jul 4, 2020
We should probably do what @danmosemsft suggests here. As this original issue is closed. Could you do the honors of creating an issue for F# with your repro here: https://github.com/dotnet/fsharp/issues?
reinux commentedon Jul 4, 2020
Running it in the VS debugger, I get this exception, which is really bonkers:
reinux commentedon Jul 4, 2020
All right, let me dig in a little deeper to see if I can isolate the issue more, because the conditions for it to occur seem to have changed on me...
reinux commentedon Jul 4, 2020
@abelbraaksma Are you using paket by any chance? If I add a reference to IdentityModel using paket, then remove the reference, the problem persists.
But if I just add using
dotnet add package, it seems to be fine.I think this is the problem: fsprojects/Paket#3721
abelbraaksma commentedon Jul 4, 2020
No, I'm working on optimizations for FSharp.Core.dll and it runs certain tests that, after my optimizations, exhibited this error. All points to references, indeed. But I don't think it is isolated with Paket, at least not for me.
But whatever the repro, the error as shown here should simply not be raised. I mean, the TypeInitializationException is kind of "normal" and can be solved (it indicates a bug by itself), but the "Cannot print exception string" certainly shouldn't happen, unless it was caused by deliberately evil user code.
reinux commentedon Jul 4, 2020
It seems to be because this version of paket (which I just realized is 5 months old now...) is removing
FSharp.Core.dll. So my theory currently is this:Exception.ToString()Exception.ToString()so it showsTypeInitializationExceptioninstead, or it tries to call FSharp.Core.dll for some other purpose prior, and notices it's missingdotnet run, on the other hand, just shows this "not-even-an-exception error message" because they didn't expect top-level exception handling to depend in any way on a (potentially missing) library.I have a really strong hunch that updating paket will fix this problem for me, and so it's probably not going to be reproducible in this way for other people with the steps I used.
Just wanted to run it by you before I do, in case you can think of a good way to express this problem to whomever might be in a position to improve it, which is kind of starting to look like more the dotnet runtime people if anything.
Hmm...
abelbraaksma commentedon Jul 4, 2020
Looks like your reference to the Paket issue, and your analysis, all point in the same direction: a missing dll, specifically FSharp.Core.
I still feel it shouldn't throw that error "cannot print etc", even though we know the cause.
The reason you see the type load exception, is because when debugging, you see the first chance exceptions. If there's no debugger attached, it goes to the exception handler (which defaults to printing the error, which it can't).
reinux commentedon Jul 4, 2020
I agree. It would have saved me a lot of time if the message were more specific. Maybe I'll bring that up on https://github.com/dotnet/runtime/issues .
Oh right, I forgot about that.
Edit: Side note: The problem with the GetDiscoveryDocumentAsync extension method not being found by FSI seems to be unrelated. Referencing the extension method by its actual name seems to work:
IdentityModel.Client.HttpClientDiscoveryExtensions.GetDiscoveryDocumentAsync( client, address = "https://localhost:7000")Tried a few experiments with async extension methods with default parameters and such, but I couldn't nail down exactly why this is happening with this particular method.