Unplanned
Last Updated: 23 Apr 2020 06:31 by ADMIN
Thomas
Created on: 18 Apr 2020 18:51
Type: Bug Report
0
Nested foreach decompilation result in an exception

Decompiling the following code in either DEBUG or RELEASE build gives the exception below:

 

        public IEnumerable<int> YieldTest(IEnumerable<int> sequenceA, List<int> sequenceB)
        {
            foreach (var i in sequenceA)
            {
                foreach (var j in sequenceB)
                {
                    yield return i*j;
                }
            }
        }

 

So a foreach nested inside another foreach...

 

Current member / type: System.Collections.Generic.IEnumerable`1<System.Int32> Tests.TestClass::YieldTest(System.Collections.Generic.IEnumerable`1<System.Int32>,System.Collections.Generic.List`1<System.Int32>)
File path: C:\Projects\Sandbox\Decompile Test\Tests\Tests\bin\Release\Tests.dll

Product version: 2019.1.118.0
Exception in: System.Collections.Generic.IEnumerable<System.Int32> YieldTest(System.Collections.Generic.IEnumerable<System.Int32>,System.Collections.Generic.List<System.Int32>)

Invalid state value
at €—..(‚ ž, Queue`1 , ILogicalConstruct ”) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\LogicFlow\YieldGuardedBlocksBuilder.cs:line 203
at €—..Ÿ(‚ ž) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\LogicFlow\YieldGuardedBlocksBuilder.cs:line 187
at €—..(‚ ž) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\LogicFlow\YieldGuardedBlocksBuilder.cs:line 129
at €—..š(„ ‚) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\LogicFlow\YieldGuardedBlocksBuilder.cs:line 76
at €—..() in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\LogicFlow\LogicalFlowBuilderStep.cs:line 126
at €—..œ(DecompilationContext ™, •Ÿ €–) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\LogicFlow\LogicalFlowBuilderStep.cs:line 51
at ‚–.™“.(MethodBody €–, •Ÿ Ÿ, ILanguage ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\DecompilationPipeline.cs:line 88
at ‚–.™“.‹(MethodBody €–, ILanguage ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\DecompilationPipeline.cs:line 70
at Telerik.JustDecompiler.Decompiler.Extensions.“(MethodBody €–, DecompilationContext †, Œ Ÿ“, Func`2 ”, DecompilationContext& ”“) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\Extensions.cs:line 104
at Telerik.JustDecompiler.Decompiler.Extensions.”(MethodBody €–, DecompilationContext †, ž& ž) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\Extensions.cs:line 139
at ž..–() in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Steps\RebuildYieldStatementsStep.cs:line 134
at ž..Match(‰ œ—) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Steps\RebuildYieldStatementsStep.cs:line 49
at ž..œ(DecompilationContext ™, •Ÿ €–) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Steps\RebuildYieldStatementsStep.cs:line 20
at ‚–.™“.(MethodBody €–, •Ÿ Ÿ, ILanguage ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\DecompilationPipeline.cs:line 88
at ‚–.™“.‹(MethodBody €–, ILanguage ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\DecompilationPipeline.cs:line 70
at Telerik.JustDecompiler.Decompiler.Extensions.›“(™“ œ“, ILanguage , MethodBody €–, DecompilationContext& ™) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\Extensions.cs:line 95
at Telerik.JustDecompiler.Decompiler.Extensions.š“(MethodBody €–, ILanguage , DecompilationContext& ™,  œ–) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\Extensions.cs:line 58
at ——.ƒ˜.—(ILanguage , MethodDefinition €,  œ–) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\WriterContextServices\BaseWriterContextService.

 

I also send an email about this when I encountered it earlier but here is an actual code example.

Attached Files:
1 comment
ADMIN
Nick Iliev
Posted on: 23 Apr 2020 06:31

Hi Thomas,

 

Once again thatn you for your detailed observations and the provided snippet. Confirming that indeed this looks like a legit bug and is reproducible when we have nested foreach and specific code structure. We will post any related information for this issue in this thread.

 

Regards,
Nick Iliev
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.