Bug 7564 - mono_aot_find_jit_info () is not signal safe
Summary: mono_aot_find_jit_info () is not signal safe
Alias: None
Product: Runtime
Classification: Mono
Component: JIT ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2012-10-01 08:44 UTC by Zoltan Varga
Modified: 2014-11-10 05:07 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Zoltan Varga 2012-10-01 08:44:57 UTC
The above function is not signal safe, but it is called from mono_jit_info_table_find () which is supposed to be signal safe.
This causes deadlocks when it is called from a signal context, which happens in a lot of places inside the runtime.

This issue is similar to https://bugzilla.xamarin.com/show_bug.cgi?id=2190, but it happens outside the debugger too, like
in is_ip_in_managed_allocator () when using sgen.
Comment 1 Zoltan Varga 2012-10-01 09:04:55 UTC
Added a workaround in 6e2cd82527056eb83396db4a40196cf929d975f0 to the sgen case, which only works on platforms with no managed allocators/write barrier methods, i.e. sgen on mt.
Comment 2 Zoltan Varga 2012-10-02 00:59:51 UTC
A complete solution would be loading this information when an AOT method is loaded, like we do when debugging is enabled. This would completely solve the issue, but it would have performance implications, i.e.:
- loading this information would take time and consume memory.
- we would have to disable direct calls between AOT methods.
Comment 3 Charles Randall 2013-08-14 12:47:09 UTC
According to Zoltan, the occasional hangs/timeouts I'm seeing with mono/tests/delegate2.exe are due to this problem. In the test framework, the test times out. When run manually, it actually hangs.

My platform is OpenSuse 12.3/amd64.

When hung, "strace -p" says it is stuck here,

futex(0x1b9cf0c, FUTEX_WAIT_PRIVATE, 3, NULL

Work around with,

mono -O=-aot delegate2.exe

Without the workaround, I was seeing a timeout about 10% of the time. With this workaround, I've run thousands of iterations and not seeing the hang.

Documenting this so users/google can find it. E.g., a search for "mono hang futex" should find this.
Comment 4 Zoltan Varga 2014-11-10 05:07:51 UTC
This was fixed some time ago.