Monobjc / monobjc

Git Repository for the Monobjc Project
http://www.monobjc.net/
17 stars 3 forks source link

Monobjc 6.0.2710.0 crashes on OS X versions prior to Mavericks #432

Open lemonmojo opened 9 years ago

lemonmojo commented 9 years ago

Since upgrading to Monobjc 6.0.2710.0 any Monobjc application crashes instantly upon launch when running on any OS X version prior to Mavericks.

Here's the console output from a new application created with the Xamarin Studio Monobjc Console App Template:

MonobjcPreMountainLionTest[265:707] -[NSProcessInfo operatingSystemVersion]: unrecognized selector sent to instance 0x7b32f6e0

Unhandled Exception:
Monobjc.ObjectiveCException: -[NSProcessInfo operatingSystemVersion]: unrecognized selector sent to instance 0x7b32f6e0
  at (wrapper managed-to-native) Monobjc.ObjectiveCRuntime:BootstrapInternal (string)
  at Monobjc.ObjectiveCRuntime.Bootstrap (System.String domainToken) [0x00000] in <filename unknown>:0 
  at Monobjc.ObjectiveCRuntime.Initialize (System.String domainToken) [0x00000] in <filename unknown>:0 
  at MonobjcPreMountainLionTest.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: Monobjc.ObjectiveCException: -[NSProcessInfo operatingSystemVersion]: unrecognized selector sent to instance 0x7b32f6e0
  at (wrapper managed-to-native) Monobjc.ObjectiveCRuntime:BootstrapInternal (string)
  at Monobjc.ObjectiveCRuntime.Bootstrap (System.String domainToken) [0x00000] in <filename unknown>:0 
  at Monobjc.ObjectiveCRuntime.Initialize (System.String domainToken) [0x00000] in <filename unknown>:0 
  at MonobjcPreMountainLionTest.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0

To me it looks like https://github.com/Monobjc/monobjc/commit/3d421435cbc8c5d38503c2d036ae5a17321f04a2 is the culprit. Since -[NSProcessInfo operatingSystemVersion] is only available since Yosemite it can't be used on older versions. Interestingly it works just fine on a fully patched Mavericks machine. But anything below that, exhibits the crash mentioned above. My guess is that one of the recent Mavericks patches brought support for the property but it probably won't be available on a vanilla installation.

letiemble commented 9 years ago

Hi,

I have uploaded a new package that reverts the previous code for version detection. My test environment has broken and I was too confident that the method will be supported (I mis-read 10.10 and 10.0).

Let me know if you have other issues.

Laurent.

2014-12-15 17:02 GMT+01:00 Felix Deimel notifications@github.com:

Since upgrading to Monobjc 6.0.2710.0 any Monobjc application crashes instantly upon launch when running on any OS X version prior to Mavericks.

Here's the console output from a new application created with the Xamarin Studio Monobjc Console App Template:

MonobjcPreMountainLionTest[265:707] -[NSProcessInfo operatingSystemVersion]: unrecognized selector sent to instance 0x7b32f6e0

Unhandled Exception: Monobjc.ObjectiveCException: -[NSProcessInfo operatingSystemVersion]: unrecognized selector sent to instance 0x7b32f6e0 at (wrapper managed-to-native) Monobjc.ObjectiveCRuntime:BootstrapInternal (string) at Monobjc.ObjectiveCRuntime.Bootstrap (System.String domainToken) [0x00000] in :0 at Monobjc.ObjectiveCRuntime.Initialize (System.String domainToken) [0x00000] in :0 at MonobjcPreMountainLionTest.Program.Main (System.String[] args) [0x00000] in :0 [ERROR] FATAL UNHANDLED EXCEPTION: Monobjc.ObjectiveCException: -[NSProcessInfo operatingSystemVersion]: unrecognized selector sent to instance 0x7b32f6e0 at (wrapper managed-to-native) Monobjc.ObjectiveCRuntime:BootstrapInternal (string) at Monobjc.ObjectiveCRuntime.Bootstrap (System.String domainToken) [0x00000] in :0 at Monobjc.ObjectiveCRuntime.Initialize (System.String domainToken) [0x00000] in :0 at MonobjcPreMountainLionTest.Program.Main (System.String[] args) [0x00000] in :0

To me it looks like 3d42143 https://github.com/Monobjc/monobjc/commit/3d421435cbc8c5d38503c2d036ae5a17321f04a2 is the culprit. Since -[NSProcessInfo operatingSystemVersion] is only available since Yosemite it can't be used on older versions. Interestingly it works just fine on a fully patched Mavericks machine. But anything below that, exhibits the crash mentioned above. My guess is that one of the recent Mavericks patches brought support for the property but it probably won't be available on a vanilla installation.

— Reply to this email directly or view it on GitHub https://github.com/Monobjc/monobjc/issues/432.

lemonmojo commented 9 years ago

@letiemble Cool, thx! Will take me some time to test this because I'm currently using a modified Monobjc version compiled from source. That's because I still have issues with this line: https://github.com/Monobjc/monobjc/blob/5ebe22a9b2475c5cd0c8860f7eccb9fb23bf7952/libraries/Monobjc/Class.cs#L129

This causes exceptions like this one every now and then:

System.TypeInitializationException: An exception was thrown by the type initializer for remojoConnectionTypes.Web.PropertyPageWebMainController ---> Monobjc.ObjectiveCException: No ObjectiveCClass attribute found for type 'Monobjc.Class'
  at Monobjc.Class.GetAttributeName (System.Type type) [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) Monobjc.Class:Get (string)
  at Monobjc.Class.Get (System.Type type) [0x00000] in <filename unknown>:0 
  at remojoConnectionTypes.Web.PropertyPageWebMainController..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at remojoConnectionTypes.Web.WebPropertyPages..ctor () [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0 

I have already looked over all of my projects and there's no class that should be exposed to the Objective-C runtime that doesn't have a ObjectiveCClass attribute. What I did is replace the line with return "Class"; which seems to get rid of the issue. I can't say for certain that it completely fixes the issue because it's a rather rare bug, but I haven't seen it ever since making the change.

lemonmojo commented 9 years ago

@letiemble Just tested 6.0.2744.0 (using your Mono 3.12.0 x64 package) and the NSProcessInfo bug is gone.