neo-project / neo-devpack-dotnet

NEO Development Pack
MIT License
79 stars 100 forks source link

Optimizer should record whether to continue execution after ENDFINALLY in TryStack #1105

Closed Hecate2 closed 1 month ago

Hecate2 commented 1 month ago

With respect to the variable throwed in https://github.com/neo-project/neo-devpack-dotnet/blob/958b63d1e534247240245143187c46224f74d54f/src/Neo.Compiler.CSharp/Optimizer/Analysers/InstructionCoverage.cs#L147 Here we have a throwed in each basic block context. In other words, only a single throwed state is available in a single recursive call. If we represent whether Exception had been with a single variable bool throwed, we may face trouble in a try nested in a finally:

try{throw ...}
// no catch
finally
{
    try {do_something();}
}

In do_something(), the variable throwed is true because we throwed from the outer try. But nothing had been throwed in the inner try.

This has been fixed in https://github.com/neo-project/neo-devpack-dotnet/pull/1102/commits/c0a0eefc4ba929384c87385d76659a4ccfd7b8c5 in https://github.com/neo-project/neo-devpack-dotnet/pull/1102