[Mono-osx] Process.Start causes SIGSEGV

Chu rscott at computerlabsolutions.com
Tue Feb 1 10:53:53 EST 2011


Mono version: 2.8.2 
OS: MacOSX Snow Leopard

I've got a simple process running on MacOSX that checks for Idle time. It
uses ProcessStart to execute a command and read in the output generated by
it.

After running this small process about 250 times, Mono crashes with a
SIGSEGV and the following dump. Additionally, the code doesn't seem to be
trappable. Mono ignores the try/catch and dies either way.

Is there a way around this? Is it a known problem in mono?

Stacktrace:

  at (wrapper managed-to-native)
System.Diagnostics.Process.CreateProcess_internal
(System.Diagnostics.ProcessStartInfo,intptr,intptr,intptr,System.Diagnostics.Process/ProcInfo&)
<0x00003>
  at (wrapper managed-to-native)
System.Diagnostics.Process.CreateProcess_internal
(System.Diagnostics.ProcessStartInfo,intptr,intptr,intptr,System.Diagnostics.Process/ProcInfo&)
<0x00003>
  at System.Diagnostics.Process.Start_noshell
(System.Diagnostics.ProcessStartInfo,System.Diagnostics.Process) <0x0083b>
  at System.Diagnostics.Process.Start_common
(System.Diagnostics.ProcessStartInfo,System.Diagnostics.Process) <0x000e9>
  at System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo)
<0x00053>
  at IdleTimeMacConsole.Program.getIdleTimeMethod1 () <0x000a2>
  at IdleTimeMacConsole.Program.pollPowerChange (object) <0x0000a>
  at System.Threading.Timer/Scheduler/<SchedulerThread>c__AnonStorey3.<>m__6
(object) <0x00060>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object
(object,intptr,intptr,intptr) <0x00041>

Native stacktrace:

	0   mono                                0x000c96ef
mono_handle_native_sigsegv + 343
	1   mono                                0x00010519
mono_sigsegv_signal_handler + 306
	2   libSystem.B.dylib                   0x911db46b _sigtramp + 43
	3   ???                                 0xffffffff 0x0 + 4294967295
	4   mono                                0x00241c58 _wapi_handle_unref + 159
	5   mono                                0x002424d5 CloseHandle + 93
	6   mono                                0x001e7a9a
ves_icall_System_Diagnostics_Process_CreateProcess_internal + 1343
	7   ???                                 0x0066170e 0x0 + 6690574
	8   ???                                 0x006606fc 0x0 + 6686460
	9   ???                                 0x0065fd4a 0x0 + 6683978
	10  ???                                 0x0065fa74 0x0 + 6683252
	11  ???                                 0x0065f583 0x0 + 6681987
	12  ???                                 0x0065f48b 0x0 + 6681739
	13  ???                                 0x0065f451 0x0 + 6681681
	14  ???                                 0x004cfc02 0x0 + 5045250
	15  mono                                0x000102e4 mono_jit_runtime_invoke
+ 1339
	16  mono                                0x001df415 mono_runtime_invoke +
138
	17  mono                                0x001e0542
mono_runtime_delegate_invoke + 111
	18  mono                                0x00217f19 mono_async_invoke + 148
	19  mono                                0x0021a717 async_invoke_thread +
749
	20  mono                                0x0021c49b start_wrapper + 600
	21  mono                                0x0025a2bb thread_start_routine +
194
	22  mono                                0x0028b813 GC_start_routine + 107
	23  libSystem.B.dylib                   0x911a285d _pthread_start + 345
	24  libSystem.B.dylib                   0x911a26e2 thread_start + 34

Debug info from gdb:


=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================


To reproduce this problem, create a console app with the following code:

static void Main(string[] args) {
            Timer pollTimer = new Timer(new TimerCallback(pollPowerChange),
null, new TimeSpan(0, 0, 0), TimeSpan.FromMilliseconds(500));

            var run = true;
            while (run) {
                var key = Console.ReadKey();
                if (key.Key == ConsoleKey.Q) {
                    run = false;
                }
            }
        }

        private static void pollPowerChange(object ignore){
            Console.WriteLine(string.Format("Idle Time: {0}",
getIdleTimeMethod1()));
        }

        private static double getIdleTimeMethod1() {
            try {

                // Initialize to a value that we are guranteed to find a
idle time less than.
                Int64 idle = Int64.MaxValue;

                // Run ioreg to get a whole slew of information.
                ProcessStartInfo ioregInfo = new ProcessStartInfo("ioreg",
"-c IOHIDSystem");
                ioregInfo.UseShellExecute = false;
                ioregInfo.RedirectStandardOutput = true;                
                
                using (var ioreg = Process.Start(ioregInfo)) {
                        
                    // Look for the parts that have to do with Idle Time,
and pick the lowest one.
                    foreach (Match match in
Regex.Matches(ioreg.StandardOutput.ReadToEnd(), @"""HIDIdleTime"" = (\d+)"))
{
                        Int64 val = Int64.Parse(match.Groups[1].Value);
                        if (val < idle) {
                            idle = val;
                        }
                    }

                    // Convert the value to seconds.
                    idle = idle / 1000000000;
                }
                
                return new TimeSpan(0, 0, (int)idle).TotalSeconds;
            } catch {
                return -1;
            }
        }
-- 
View this message in context: http://mono.1490590.n4.nabble.com/Process-Start-causes-SIGSEGV-tp3251954p3251954.html
Sent from the Mono - OSX mailing list archive at Nabble.com.


More information about the Mono-osx mailing list