Bug 5053 - Get property calls to GLKBaseEffect abort
Summary: Get property calls to GLKBaseEffect abort
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.2
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Rolf Bjarne Kvinge [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2012-05-13 15:58 UTC by Bill Holmes
Modified: 2012-05-14 20:21 UTC (History)
2 users (show)

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


Attachments
Sample to reporduce (1.43 KB, application/octet-stream)
2012-05-13 15:58 UTC, Bill Holmes
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 Developer Community or GitHub 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 Bill Holmes 2012-05-13 15:58:04 UTC
Created attachment 1870 [details]
Sample to reporduce

Here are the properties that I am having problems with.   

GLKBaseEffect.Transform.ModelViewMatrix
GLKBaseEffect.Light0.AmbientColor

There are more problems in this area s well. 

Compile and run the attached sample.  Code will abort in drawInRect method.  

Stacktrace:

  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging.Vector4_objc_msgSend_stret (OpenTK.Vector4&,intptr,intptr) <IL 0x00025, 0xffffffff>
  at MonoTouch.GLKit.GLKEffectPropertyLight.get_AmbientColor () [0x0000b] in /Developer/MonoTouch/Source/monotouch/src/GLKit/GLKEffectPropertyLight.g.cs:125
  at Application.MyGLViewCtrl.drawInRect (MonoTouch.GLKit.GLKView,System.Drawing.RectangleF) [0x00036] in /Users/williamholmes/Documents/Del/2012-05-13/2012-05-13/AppDelegate.cs:65
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object_RectangleF (object,intptr,intptr,intptr) <IL 0x00064, 0xffffffff>
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
  at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
  at Application.Application.Main (string[]) [0x00000] in /Users/williamholmes/Documents/Del/2012-05-13/2012-05-13/Main.cs:17
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

Native stacktrace:

	0   20120513                            0x0009094c mono_handle_native_sigsegv + 284
	1   20120513                            0x00005cd8 mono_sigsegv_signal_handler + 248
	2   libsystem_c.dylib                   0x9a19059b _sigtramp + 43
	3   ???                                 0xffffffff 0x0 + 4294967295
	4   ???                                 0x0e2639b4 0x0 + 237386164
	5   ???                                 0x0e263870 0x0 + 237385840
	6   ???                                 0x0e262740 0x0 + 237381440
	7   ???                                 0x0e262995 0x0 + 237382037
	8   20120513                            0x0000a042 mono_jit_runtime_invoke + 722
	9   20120513                            0x00169f4e mono_runtime_invoke + 126
	10  20120513                            0x00206748 monotouch_trampoline + 3416
	11  GLKit                               0x03440ea4 -[GLKView _display:] + 348
	12  GLKit                               0x03441493 -[GLKView displayLayer:] + 53
	13  QuartzCore                          0x041a1fb1 _ZN2CA5Layer7displayEv + 129
	14  QuartzCore                          0x0419ba63 -[CALayer display] + 33
	15  QuartzCore                          0x041a59ae _ZN2CA5Layer17display_if_neededEPNS_11TransactionE + 256
	16  QuartzCore                          0x0412a509 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 395
	17  QuartzCore                          0x0412c3f6 _ZN2CA11Transaction6commitEv + 374
	18  QuartzCore                          0x041b9160 +[CATransaction flush] + 52
	19  UIKit                               0x021bbe84 -[UIApplication _reportAppLaunchFinished] + 39
	20  UIKit                               0x021bc767 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 1791
	21  UIKit                               0x021cb183 -[UIApplication handleEvent:withNewEvent:] + 1027
	22  UIKit                               0x021cbc38 -[UIApplication sendEvent:] + 68
	23  UIKit                               0x021bf634 _UIApplicationHandleEvent + 8196
	24  GraphicsServices                    0x047c5ef5 PurpleEventCallback + 1274
	25  CoreFoundation                      0x011a9195 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
	26  CoreFoundation                      0x0110dff2 __CFRunLoopDoSource1 + 146
	27  CoreFoundation                      0x0110c8da __CFRunLoopRun + 2218
	28  CoreFoundation                      0x0110bd84 CFRunLoopRunSpecific + 212
	29  CoreFoundation                      0x0110bc9b CFRunLoopRunInMode + 123
	30  UIKit                               0x021bbc65 -[UIApplication _run] + 576
	31  UIKit                               0x021bd626 UIApplicationMain + 1163
	32  ???                                 0x0e257a05 0x0 + 237337093
	33  ???                                 0x0de39f50 0x0 + 233021264
	34  ???                                 0x0de39c48 0x0 + 233020488
	35  ???                                 0x0de39d9e 0x0 + 233020830
	36  20120513                            0x0000a042 mono_jit_runtime_invoke + 722
	37  20120513                            0x00169f4e mono_runtime_invoke + 126
	38  20120513                            0x0016e034 mono_runtime_exec_main + 420
	39  20120513                            0x00173455 mono_runtime_run_main + 725
	40  20120513                            0x00067245 mono_jit_exec + 149
	41  20120513                            0x002116a5 main + 2837
	42  20120513                            0x00003095 start + 53

=================================================================
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.
=================================================================
Comment 1 Rolf Bjarne Kvinge [MSFT] 2012-05-14 19:45:26 UTC
Fixed (unit tests included) in MonoTouch master (99bc29). The fix will be in the 5.3.4 release.

I'm not entirely sure this should go into 5.2 yet, I'll keep the bug open until I've decided what to do.

The problem is that the properties which return Matrix4/Vector4 takes a pointer to the return value, and that pointer needs to be 16-bit aligned. It is possible to work around this issue (but it's a bit ugly), not tested but this should give you the idea:

[DllImport ("libc.dylib", "objc_msgSend_stret")
static extern void obj_msgSend_stret (IntPtr retval, IntPtr receiver, IntPtr selector);

IntPtr abuffer = Marshal.AllocHGlobal (sizeof (Vector4) + 16);
IntPtr buffer = new IntPtr (((aBuffer.ToInt32 () + 15) >> 4) << 4); // align to 16 bits

obj_msgSend_stret (buffer, _effect.Light0.Handle, new Selector ("ambientColor").Handle);

Vector4 result;
unsafe { result = * (Vector4 *) buffer; }
Comment 2 Rolf Bjarne Kvinge [MSFT] 2012-05-14 20:21:00 UTC
The fix has been backported to the 5.2-series (3426d8). First release with this fix will be 5.2.12.