Bug 8550 - Struct marshaling results in EXC_BAD_ACCESS crash
Summary: Struct marshaling results in EXC_BAD_ACCESS crash
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: Master
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: 2.0.x
Assignee: Rolf Bjarne Kvinge [MSFT]
Depends on:
Reported: 2012-11-21 21:22 UTC by Aaron Oneal
Modified: 2015-03-09 08:59 UTC (History)
6 users (show)

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

Sample code to see what the marshaling setup looks like (7.92 KB, application/zip)
2012-11-21 21:22 UTC, Aaron Oneal
Native/managed repro projects and crash output (3.34 MB, application/zip)
2013-05-20 14:13 UTC, Aaron Oneal

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:

Description Aaron Oneal 2012-11-21 21:22:50 UTC
Created attachment 2995 [details]
Sample code to see what the marshaling setup looks like

Marshaling this struct results in a crash when calling back into a managed code protocol implementation from Objective-C.

struct MyStruct
    NSString* theString;
    int intNumber;
    long long longNumber;
    bool boolVal;
    int finalIntNumber;

- (void) startTest
    struct MyStruct ms = [delegate testStructReturn];

MonoDevelop 3.0.5
	Mono 2.10.9 (tarball)
	GTK 2.24.10
	GTK# (
	Package version: 210090011
Apple Developer Tools:
	 Xcode 4.5.2 (1847)
	 Build 4G2008a
Operating System:
	Mac OS X 10.8.2
	Darwin Kernel Version 12.2.1
Comment 1 Miguel de Icaza [MSFT] 2013-05-15 00:15:32 UTC
Please attach with gdb and include the stack trace.
Comment 2 Aaron Oneal 2013-05-20 14:13:24 UTC
Created attachment 3994 [details]
Native/managed repro projects and crash output

I'm attaching a full repro and crash output. It contains a native dylib which invokes the managed protocol implementation.
Comment 3 Chris Hamons 2015-02-17 13:37:15 UTC

Apologies on the long delay in response to this bug. It was misfiled and thus overlooked. I've taken a look, and at first glance it appears to be a problem still.

Rolf - I think this is a runtime issue? Do you think this is something that is your area? Else, bounce back.
Comment 4 Rolf Bjarne Kvinge [MSFT] 2015-02-19 09:00:08 UTC
This works fine with maccore/master, so it looks like we've fixed it quite recently ( still crashes).
Comment 5 Rajneesh Kumar 2015-03-05 04:42:17 UTC
We are trying to verify this issue, but we are not sure about the steps to check or verify this issue.
I checked this issue with the attached sample, after migrating it in to Unified API getting build error. Here is the screencast for the same: http://www.screencast.com/t/Wn23LAhGHZQu

Could you please share steps check this issue? So that we can verify it efficiently.

Ide Logs: https://gist.github.com/Rajneesh360Logica/73e0656deda75923c10f
Environment info: https://gist.github.com/Rajneesh360Logica/71300481f5712a0f8639
Build Output: https://gist.github.com/Rajneesh360Logica/f87562e0ae29e96a08c5

Comment 6 Rolf Bjarne Kvinge [MSFT] 2015-03-05 05:07:28 UTC
* Download the attachment from comment #2
* Open TestParameters.sln from inside the zip
* Chose "Migrate to Xamarin.Mac" when Xamarin Studio asks for it
* Clean & rebuild & run the project.
* It should not crash at startup.

There is no need to convert the app to Unified to verify this bug.
Comment 7 Rajneesh Kumar 2015-03-09 08:58:56 UTC
@ Rolf, Thanks a lot for providing the the steps to check/verify this issue. 

I have checked this issue with the following builds:

Xamarin Studio Version 5.9 (build 126)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
Mono 4.0.0 ((detached/51d34c6)
GTK+ 2.24.23 (Raleigh theme)
Package version: 400000028
Apple Developer Tools Xcode 6.2 (6770) 
Build 6C121
Xamarin.Mac Version: (Business Edition)
=== Build Information ===
Release ID: 509000126
Git revision: 1655605cb3fe05b3d63c8afbf9b2900f2f08771d
Build date: 2015-03-04 06:17:59-05
Xamarin addins: 564d7bb0d7d0bc4440c14e7baf16db2fadb76975
Operating System Mac OS X 10.9.5
Darwin MacMini.local 13.4.0 Darwin Kernel Version 13.4.0
Sun Aug 17 19:50:11 PDT 2014
root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64

To check this issue I have followed the steps provided in comment 6. I observed that user is able to run the application and It does't crash at startup. Here is the screencast for the same: http://www.screencast.com/t/ZAgtsThaKbca

This issue has been fixed, hence I am closing this issue.