Update for Windows 10 Creators.net 4.7 System.AccessViolationException Problem

After updating the update for Windows 10 with .net 4.7, I have a critical problem while running very simple code.

Description: The process was aborted due to an unhandled exception. Exception Information: System.AccessViolationException

class Program { private int? m_bool; private bool prop {get{ return false;}} void test() { //nothing } private object Test() { if (prop) { try { test(); } catch (Exception) {} m_bool = 1; } return null; } static void Main(string[] args) { new Program().Test(); } } 

A similar problem seems to be https://github.com/dotnet/coreclr/issues/10826

Does anyone know how to avoid this?

+5
source share
1 answer

The problem occurs when optimization is performed on an unreachable base unit. In your case, the compiler encloses the get_prop method (which unconditionally returns false). This leads to the JIT compiler treating the region as unreachable. Typically, the JIT compiler removes unreachable code before starting the optimization, but adding a try / catch scope causes JIT not to delete these base blocks.

If you want to prevent this problem, you can disable the optimization, disable the embedding of get_prop or change the implementation of the get_prop method as follows:

  static bool s_alwaysFalse = false; private bool prop {get{ return s_alwaysFalse;}} 

We had several reports about this problem, and we have a ready-made solution, and it will be provided to users in the upcoming update.

+4
source

Source: https://habr.com/ru/post/1266962/


All Articles