Bug 11315 - Potential DeadLock in processes.c when fork failed
Summary: Potential DeadLock in processes.c when fork failed
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: io-layer ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-03-21 06:16 UTC by gilles.grospellier
Modified: 2013-03-21 21:23 UTC (History)
3 users (show)

Tags:
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:
Status:
RESOLVED FIXED

Description gilles.grospellier 2013-03-21 06:16:53 UTC
In mono version 3.0.6, in file io-layer/processes.c, in function CreateProcess, the fork() function is called line 965.
If the fork failed,  _wapi_handle_unref() is called and deadlock because it try to lock shared handle (via _wapi_handle_lock_shared_handles) and the lock is already taken before the fork call (line 961), which result in a deadlock. One solution is to release the lock before calling _wapi_handle_unref() and take it again after (because it is released during cleanup).

Also, when fork failed you suppose the error is ENOMEM but it may also be EAGAIN when too many process are launched at the same time.
Comment 1 Zoltan Varga 2013-03-21 21:23:28 UTC
Fixed in master/mono-2-10 branches.