Bug 17101 - Crash on delegate call on custom library when deploying to device.
Summary: Crash on delegate call on custom library when deploying to device.
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 7.0.2.x
Hardware: PC Mac OS
: Normal normal
Target Milestone: 7.2.1
Assignee: Zoltan Varga
Depends on:
Reported: 2014-01-07 16:25 UTC by Jon Goldberger [MSFT]
Modified: 2014-03-21 12:42 UTC (History)
6 users (show)

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

Stack Trace (5.35 KB, text/plain)
2014-01-07 16:27 UTC, Jon Goldberger [MSFT]

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:

Comment 1 Jon Goldberger [MSFT] 2014-01-07 16:26:17 UTC
From case file:

I'm the author of a library made for recording/playing video. This library
is made in Objective-C but provides bindings for the Xamarin Framework. I'm
experiencing a crash though when using SCPlayer which is an object that
inherits from AVPlayer and add some features. In the objective-c layer,
this object can have a delegate for dispatching messages such as "didPlay"
for informing that the player played some audio/video samples. This
particular method has the following signature:

- (void) videoPlayer:(SCPlayer*)videoPlayer didPlay:(CMTime)secondsElapsed

And the following C# binding:

[Export("videoPlayer:didPlay:timeTotal:"), EventArgs("PlayerDidPlay")]
void DidPlay(SCPlayer player, CMTime secondsElapsed, CMTime secondsTotal);

The problem is that when this particular delegate is called, the program
gets a segmentation fault at the end of the C# method. In the attached
files, you'll find a tiny solution that shows this error and the
stacktrace. Even though I provided the compiled library (in dll), you'll
find the native objective-c library as well (the file that send the didPlay
message is SCPlayer.m, in the init method). The bindings are in the
XamarinBindings/SCAudioVideoRecorderBindings/ApiDefinition.cs file. You can
recompile the binding by typing "make" in the XamarinBindings directory.
This will generate SCAudioVideoRecorder.dll that you'll have to move in the
root directory so the solution will use it.
Comment 2 Jon Goldberger [MSFT] 2014-01-07 16:27:04 UTC
Created attachment 5778 [details]
Stack Trace
Comment 3 Rolf Bjarne Kvinge [MSFT] 2014-01-07 19:08:33 UTC
Zoltan, this looks like this is a bug in the dynamic calling code on ARM.

It crashes in mono_arch_finish_dyn_call here:

     *(gpointer*)ret = NULL;

because ret = NULL.

Putting a watchpoint on &((DynCallArgs*) buf)->ret shows that this value is overwritten to NULL in mono_arch_start_dyn_call, mini-arm.c:2689 at this line:

     p->regs [slot ++] = ((mgreg_t*)arg) [j];

My guess would be that 'slot' ended up bigger than the number of registers.
Comment 4 Zoltan Varga 2014-01-07 22:35:39 UTC
Fixed in mono master b5af5b72cab414dc7d57f2d58cb52574e2c6a8d0/mt master f373d168ed791fa79a16391ec0ebcd5818cb0bc9.
Comment 6 Rolf Bjarne Kvinge [MSFT] 2014-02-27 09:39:00 UTC
This fix will be included in Xamarin.iOS 7.0.8.
Comment 7 Sadik Ali 2014-03-21 03:19:25 UTC
I have verified this issue below is my observation:

1. I am able to deploy application successfully on simulator.
2. Getting build error when I tried to deploy application in device.

Build Log: https://gist.github.com/Mohit-Kheterpal/9681121
Screen shot: http://screencast.com/t/aEzmvNdld0

There is bug reported for this type error: Bug 18344

Hence I reopened this issue.

Build Info:

=== Xamarin Studio ===
Version 4.2.4 (build 32)
Installation UUID: 449f40dd-b3f1-4028-9a6b-cca0d1a2307d
	Mono 3.2.6 ((no/9b58377)
	GTK+ 2.24.23 (Raleigh theme)
	Package version: 302060000

=== Apple Developer Tools ===
Xcode 5.1 (5084)
Build 5B130a

=== Xamarin.iOS ===
Version: (Business Edition)

=== Xamarin.Android ===
Version: 4.12.3 (Business Edition)

=== Xamarin.Mac ===

=== Build Information ===
Release ID: 402040032
Git revision: a160c35dac9ab9fd32eeadaa171216316d5a5133
Xamarin addins: a779416ceabd54981ce812771a4061c942e8b872

=== Operating System ===
Mac OS X 10.8.4
Darwin 360Logicas-Mac-mini.local 12.4.0 Darwin Kernel Version 12.4.0
    Sun Mar 10 18:01:10 PDT 2013
    root:xnu-2050.24.6~1/RELEASE_X86_64 x86_64
Comment 8 Sebastien Pouliot 2014-03-21 08:40:08 UTC
error MT4117: The registrar found a signature mismatch in the method 'SCorsin.SCCamera.AutoFocusAtPoint' - the selector 'autoFocusAtPoint' indicates the method takes 0 parameters, while the managed method has 1 parameters.
error MT4117: The registrar found a signature mismatch in the method 'SCorsin.SCCamera.ContinuousFocusAtPoint' - the selector 'continuousFocusAtPoint' indicates the method takes 0 parameters, while the managed method has 1 parameters.

^ those are additional checks done by the new registrar, it requires the test project to be updated. You need to fix the selector if you want to validate the bug (or select the old registrar), e.g. by adding ` --registrar:legacy` to the options.
Comment 9 Ram Chandra 2014-03-21 12:42:21 UTC
I have checked this issue on following builds:

Mac 10.9.3
Xamarin Studio: 4.2.4 (build 32)
Mono 3.2.6 ((no/9b58377)

I have checked this issues and I observe that to deploy the attached project into device we have to set  "aditional mtouch argument " to "--registrar:legacy" under "iOS Build" option.

screencast:  http://www.screencast.com/t/CwhshhiHmsuq

This issue is working fine. Hence, I am closing this issue.