Fix S2583/2589 FP: Return inside lock and using causes FP after the block #8495
Labels
Area: C#
C# rules related issues.
Area: CFG/SE
CFG and SE related issues.
Area: VB.NET
VB.NET rules related issues.
Type: CFG/SE FPs
Rule IS triggered when it shouldn't be for CFG and SE rules.
Milestone
We have FP when flow exists with
return
from within the explicit (try/finally) or implicit (foreach, lock, using) TryRegion/FinallyRegion.Flow
if(a)
The
return true
visits finally block withflag=true
state, and then goes to exit block.Flow
if(b)
flag
is set tofalse
, normal exit of implicit try/finally visits the finally block withflag=false
state,and then goes to exit block.Flow with
b==false
flag
remainstrue
and normal exist of implicit try/finally visits the finally block. And because this state has already been visited, it's thrown away.ToDo
Take closer look on why it doesn't reproduce on the try/finally scenario, that's part of the reproducer. It could involve LVA, where the
a
is or is not disposed properly.Possible solution
To fix this, we need to consider what are the finally blocks that should be visited after as a part of the unique key.
We need to consider
FinallyPoint
of the node, including allFinallyPoint.Previous
nodes, as the path could be different in nested scenarios.The text was updated successfully, but these errors were encountered: