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
// Generated by Fuzzlyn v1.2 on 2021-07-03 17:37:53// Seed: 10069026747560583045// Reduced from 77.5 KiB to 0.8 KiB in 00:00:53// Debug: Prints 0 line(s)// Release: Prints 1 line(s)publicclassProgram{staticushorts_6;staticuint[]s_15=newuint[]{0};staticbools_19;publicstaticvoidMain(){try{ushortvr4=s_6;}finally{boolvr5=s_19;if(vr5){s_15[0]=s_15[0];}try{if(vr5){bool[]vr6=newbool[]{false};}}finally{if(vr5){bool[]vr7=newbool[]{false};System.Console.WriteLine(vr7[0]);}}}}}
Looks like we end up somehow removing the vr5 test in the inner finally.
GenTreeNode creates assertion:
N004 ( 5, 5) [000006] ------------*JTRUE void
InBB01NewGlobalConstantAssertion: ($c0,$40) V00.02!=0, index =#02BB03 in =#02BB04 out =#02
Both are correct on their own, but lead to dataflow concluding that BB08 in = #02, which is not correct because BB08 has an additional predecessor - BB05, the special callf block, which correctly has no assertions generated for it.
Of note is the fact that BB05 has additional predecessors added to it after the redundant branch optimization:
Both successors of idom BB01 reach BB03-- attempting jump threading
BB01 is a true pred
BB02 is an eh constrained pred
Optimizing via jump threading
Jump flow from pred BB01->BB03 implies predicate true; we can safely redirect flow to be BB01->BB05
Activity
SingleAccretion commentedon Jul 4, 2021
Some notes to help whoever is more familiar with our EH handling figure out where the actual bug is.
Here's a bit less noisy reproduction:
Run with
DOTNET_JitEnableFinallyCloning=0.Here's the flow table before assertion prop:
The issue arises because dataflow only considers
try-blocks to be the predecessors of the handler's first block:runtime/src/coreclr/jit/dataflow.h
Lines 54 to 58 in ad51267
runtime/src/coreclr/jit/assertionprop.cpp
Lines 4775 to 4779 in 607f98c
(This is actually recent code, see #160)
The relevant assertion for the
tryblocks:Both are correct on their own, but lead to dataflow concluding that
BB08 in = #02, which is not correct becauseBB08has an additional predecessor -BB05, the specialcallfblock, which correctly has no assertions generated for it.Of note is the fact that
BB05has additional predecessors added to it after the redundant branch optimization:kunalspathak commentedon Jul 14, 2021
Thanks a lot @SingleAccretion for the short repro and explanation. Helped me in finding the fix!
briansull commentedon Jul 15, 2021
Triage Area: AssertionProp