Bug 2105 - Mono application run from udev rule never terminates
Summary: Mono application run from udev rule never terminates
Status: RESOLVED UPSTREAM
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-11-20 20:57 UTC by David Pfeffer
Modified: 2013-09-09 11:53 UTC (History)
4 users (show)

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


Attachments
Screenshot of gdb on a frozen thread, as called by udev (20.16 KB, image/png)
2011-11-21 15:39 UTC, David Pfeffer
Details
Demo binary that fails (3.00 KB, application/octet-stream)
2011-11-23 13:18 UTC, David Pfeffer
Details
Source code for demo binary that fails (171 bytes, text/plain)
2011-11-23 13:18 UTC, David Pfeffer
Details
strace of mono running the test binary, from the console (35.23 KB, application/octet-stream)
2011-11-23 14:06 UTC, David Pfeffer
Details
strace of mono running the test binary, from a udev rule (32.59 KB, application/octet-stream)
2011-11-23 14:06 UTC, David Pfeffer
Details
strace -f of mono running the test binary, from a udev rule (35.62 KB, text/plain)
2011-11-23 15:13 UTC, David Pfeffer
Details


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 UPSTREAM

Description David Pfeffer 2011-11-20 20:57:10 UTC
I wrote a short application to probe a character device to determine if it is a modem or not. Calling this application from the console works fine.

Calling the application from the PROGRAM= stanza of a udev rule causes the application to never terminate on certain systems only. I cannot determine what environmental factors cause the failure on which systems.

To verify that it isn't related to the application that is run, I wrote a single line Hello World application that also fails.

Attaching gdb to the non-terminated, frozen process, shows that mono is in sem_wait, called a few call stack levels down from mono_domain_finalize. gdb has no information about the 5 functions between sem_wait and mono_domain_finalize.

To reproduce (on a system where this occurs), add a udev rule to /etc/udev/rules.d called test.rules, containing:
SUBSYSTEM=="tty", PROGRAM="/path/to/mono/assembly.exe"

Then run: udevadm trigger
This will attempt to run the program for every tty device in the system.

Some additional information: using udevadm test to call the application succeeds even though it is called from the udev rule; only calling the application from the udev daemon (via trigger, or a device plug-in) fails. Additionally, to eliminate some sort of binfmt_misc failure, you can change PROGRAM= to call a shell script that calls the mono binary, passing the assembly.exe file as an argument. This still fails.
Comment 1 David Pfeffer 2011-11-21 15:39:19 UTC
Created attachment 923 [details]
Screenshot of gdb on a frozen thread, as called by udev
Comment 2 David Pfeffer 2011-11-23 13:18:38 UTC
Created attachment 936 [details]
Demo binary that fails
Comment 3 David Pfeffer 2011-11-23 13:18:56 UTC
Created attachment 937 [details]
Source code for demo binary that fails
Comment 4 David Pfeffer 2011-11-23 13:21:48 UTC
Quick update -- this has been tried on both 2.10.2 and 2.10.5. I have an Ubuntu system where this works fine (on both versions) and a Gentoo system where this always fails (also both versions).
Comment 5 David Pfeffer 2011-11-23 14:06:20 UTC
Created attachment 938 [details]
strace of mono running the test binary, from the console
Comment 6 David Pfeffer 2011-11-23 14:06:44 UTC
Created attachment 939 [details]
strace of mono running the test binary, from a udev rule
Comment 7 David Pfeffer 2011-11-23 14:48:18 UTC
Using the env -i command, I've eliminated environment variables as a cause --

env -i plus mono inside the udev rule works on one system and fails on the other, just as if we didn't use env -i
env -i plus mono on the console works on both systems
Comment 8 David Pfeffer 2011-11-23 15:13:06 UTC
Created attachment 940 [details]
strace -f of mono running the test binary, from a udev rule
Comment 9 Zoltan Varga 2011-11-25 00:16:17 UTC
Mono users on Gentoo run into lots of strange bugs not reproducible elsewhere.
Comment 10 Rodrigo Kumpera 2013-09-09 11:53:47 UTC
Gentto problems should be troubleshoot by upstream for a reliable test case.