-
-
Notifications
You must be signed in to change notification settings - Fork 635
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
Defend against cyclical Type Forwarders? #706
Comments
If you think this is worth pursuing I can send a PR. |
If we have two assemblies with type forwarders that point to each other, we enter an infinite loop and a stack overflow. This breaks the cycle by detecting reentrancy. Fixes jbevain#706
@jbevain we need to fix this, I ran into this again :( Every time I investigate this I forget I already saw this and it takes me an hour or so. This time a loop for System.Security.Cryptography.ProtectedData: |
Another cycle between System.Configuration.dll and System.Configuration.ConfigurationManager.dll |
If we have two assemblies with type forwarders that point to each other, we enter an infinite loop and a stack overflow. This breaks the cycle by detecting reentrancy. Fixes jbevain#706
I revived #806 and added a test. Should be ready to go! |
This is not necessarily a bug in Cecil per se, but something to think about to protect consumers against cyclical type forwarders.
I'm filing this primarily so that there's a record of a lengthy investigation where the symptom was a StackOverflow in Cecil with this repeating stack:
I'm attaching two .dlls where the type
System.Lazy``2
is type forwarded to the other .dll.CecilRepro.zip
Of course it's a bug where the custom assembly resolver I have resolved this combination of .dlls - normally there shouldn't be a cycle.
But I thought of how to defend against a StackOverflow here and there doesn't seem to be a way to defend against reentrancy on the consumer side.
Ideally I'd place a circuit breaker here:
cecil/Mono.Cecil/ModuleDefinition.cs
Line 741 in 6edabe0
Remember the type I'm about to start resolving by adding it to the list, and remove it at the end of the method in a finally block. At the beginning of the method, check if the type is already in the list, and if so, throw an InvalidOperationException("recursive type references") or something.
I know it's kind of an obscure edge case but something to think about.
The text was updated successfully, but these errors were encountered: