Skip to content
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

An unhandled exception of type 'System.StackOverflowException' occurred in ICSharpCode.Decompiler.dll #2180

Closed
ChristianHoe opened this issue Oct 4, 2020 · 9 comments
Labels

Comments

@ChristianHoe
Copy link

Steps to reproduce

  1. Open Dll (can be provided)
  2. Browsing to a specific class (most other seems okay)
  3. Crash

Error message shown

Eine Ausnahme vom Typ "System.StackOverflowException" wurde ausgelöst.

Details

  • Product in use: VIsual Studio 2019 (ILSpy)
  • Version in use: e.g. 6.2.0.6124
  • Opened Dll NETCoreApp, V3.1 / Linux
@siegfriedpammer
Copy link
Member

Yes, please provide the DLL. If you prefer a private channel, please send it to siegfried.pammer@gmail.com. Thanks!

@ChristianHoe
Copy link
Author

Send. There should be nothing important in the DLL.
PollAnswer in EventBot.Business.Commands.Raid

@siegfriedpammer
Copy link
Member

I haven't received anything yet...

@ChristianHoe
Copy link
Author

Send again.

@siegfriedpammer
Copy link
Member

Still nothing... no spam... nothing... sorry. Might be GMail blocking executables as attachments...

@ChristianHoe
Copy link
Author

@siegfriedpammer
Copy link
Member

Downloaded, thanks!

@siegfriedpammer
Copy link
Member

@dgrunwald the infinite recursion starts here:

if (this.ResolveResult.IsCompileTimeConstant && this.ResolveResult.ConstantValue != null
&& NullableType.IsNullable(targetType) && !utype.Equals(targetUType))
{
// Casts like `(uint?)-1` are only valid in an explicitly unchecked context, but we
// don't have logic to ensure such a context (usually we emit into an implicitly unchecked context).
// This only applies with constants as input (int->uint? is fine in implicitly unchecked context).
// We use an intermediate cast to the nullable's underlying type, which results
// in a constant conversion, so the final output will be something like `(uint?)uint.MaxValue`
return ConvertTo(targetUType, expressionBuilder, checkForOverflow, allowImplicitConversion: false)
.ConvertTo(targetType, expressionBuilder, checkForOverflow, allowImplicitConversion);
}

I am not sure, what the best fix would be.

@dgrunwald
Copy link
Member

We're starting with {0} : {[ConstantResolveResult 0200012B System.Int32 = 0]} and try to convert that to Nullable<Unknown>.
This hits the special case for converting compile-time constants to nullable types, which first converts to Unknown and then to Nullable<Unknown>.
However a conversion to Unknown is actually a no-op, so the function ends up calling itself infinitely.
I think we can restrict the special case to integer types in order to fix the recursion.

Note: the unknown types occur because the assembly references are missing. ILSpy needs to load referenced assemblies for proper decompilation.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 11, 2021
ElektroKill pushed a commit to dnSpyEx/ILSpy that referenced this issue Aug 9, 2021
…to integer types.

This avoids the risk of stack overflows when converting to an unexpected nullable type (such as `Nullable<UnknownType>`).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants