Bug 24151 - EXC_BAD_ACCESS in [WKWebView initWithFrame:configuration:] on 32-bit devices due to Unified API nfloat usage
Summary: EXC_BAD_ACCESS in [WKWebView initWithFrame:configuration:] on 32-bit devices ...
Status: RESOLVED DUPLICATE of bug 23868
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS ()
Version: 3.7
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Adrian Alonso
Depends on:
Reported: 2014-10-30 00:37 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2015-04-10 20:56 UTC (History)
6 users (show)

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

Test case (10.08 KB, application/zip)
2014-10-30 00:37 UTC, Brendan Zagaeski (Xamarin Team, assistant)

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 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 Brendan Zagaeski (Xamarin Team, assistant) 2014-10-30 00:37:31 UTC
Created attachment 8557 [details]
Test case

EXC_BAD_ACCESS in [WKWebView initWithFrame:configuration:] on 32-bit devices due to Unified API nfloat usage

This is very likely a duplicate of bug 23868.

I'm still filing a new bug anyway for 2 reasons:

(a) To record the precise stack trace of this particular error.

(b) To provide a test case that can be double-checked once the upcoming fix for bug 23868 is available.

Regression status: NOT a regression.

## Workaround

One known workaround for this problem is to build the app in Xamarin Studio on Mac.

## Steps to reproduce

Run the attached app on a 32-bit iOS 8 or iOS 8.1 device or simulator.

For example, the iPhone 4s iOS 8.1 simulator or the iPhone 5s iOS 8.1 simulator will show the problem.

Note: do *not* open the project properties before running the app. Opening the project properties can change the results due to bug 24150.

## Result

The app crashes while attempting to initialize the `WKWebView`.

### Example symbolicated crash from a hardware iPhone 5C, iOS 8.0.2

> Crash Metadata
> Incident Identifier	C21FAFAD-842A-46D6-9935-D6B55F902A80
> CrashReporter Key	01a4ee316569310e08d9ef98e0025f72ecee46a6
> Exception Subtype	KERN_INVALID_ADDRESS at 0x00000004
> Thread 0 Crashed
> 0	libsystem_kernel.dylib	0x329a6dfc	__pthread_kill (in libsystem_kernel.dylib) + 8
> 1	libsystem_pthread.dylib	0x32a24d32	pthread_kill (in libsystem_pthread.dylib) + 58
> 2	libsystem_c.dylib	0x32946904	abort (in libsystem_c.dylib) + 72
> 3	BlankAppUnifiedVS	0x2570c2	mono_handle_native_sigsegv (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) (mini-exceptions.c:2360)
> 4	BlankAppUnifiedVS	0x26127c	mono_sigsegv_signal_handler (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) (mini.c:6869)
> 5	libsystem_platform.dylib	0x32a20878	_sigtramp (in libsystem_platform.dylib) + 40
> 6	WebKit	0x28a894de	-[WKWebView initWithFrame:configuration:] (in WebKit) + 570
> 7	BlankAppUnifiedVS	0x225730	wrapper_managed_to_native_ObjCRuntime_Messaging_IntPtr_objc_msgSend_CGRect_IntPtr_intptr_intptr_CoreGraphics_CGRect_intptr (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) + 208
> 8	BlankAppUnifiedVS	0x211638	WebKit_WKWebView__ctor_CoreGraphics_CGRect_WebKit_WKWebViewConfiguration (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) + 256
> 9	BlankAppUnifiedVS	0x12e11c	BlankAppUnifiedVS_AppDelegate_FinishedLaunching_UIKit_UIApplication_Foundation_NSDictionary (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) + 944
> 10	BlankAppUnifiedVS	0x1c3e28	wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) + 196
> 11	BlankAppUnifiedVS	0x263478	mono_jit_runtime_invoke (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) (mini.c:6727)
> 12	BlankAppUnifiedVS	0x2aadf6	mono_runtime_invoke (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) (object.c:2831)
> 13	BlankAppUnifiedVS	0x22fabc	native_to_managed_trampoline_1 (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) (registrar.m:44)
> 14	BlankAppUnifiedVS	0x22ff0c	-[AppDelegate application:didFinishLaunchingWithOptions:] (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) (registrar.m:165)
> 15	UIKit	0x2817c894	-[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] (in UIKit) + 280
> 16	UIKit	0x2837177a	-[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] (in UIKit) + 2354
> 17	UIKit	0x28373cc6	-[UIApplication _runWithMainScene:transitionContext:completion:] (in UIKit) + 1370
> 18	UIKit	0x2837e544	__84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke (in UIKit) + 32
> 19	UIKit	0x28372554	-[UIApplication workspaceDidEndTransaction:] (in UIKit) + 128
> 20	FrontBoardServices	0x2b3b50e6	__31-[FBSSerialQueue performAsync:]_block_invoke (in FrontBoardServices) + 10
> 21	CoreFoundation	0x24c3a5b2	__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ (in CoreFoundation) + 10
> 22	CoreFoundation	0x24c39874	__CFRunLoopDoBlocks (in CoreFoundation) + 212
> 23	CoreFoundation	0x24c37ff6	__CFRunLoopRun (in CoreFoundation) + 758
> 24	CoreFoundation	0x24b8661c	CFRunLoopRunSpecific (in CoreFoundation) + 472
> 25	CoreFoundation	0x24b8642e	CFRunLoopRunInMode (in CoreFoundation) + 102
> 26	UIKit	0x2817656a	-[UIApplication _run] (in UIKit) + 554
> 27	UIKit	0x28171354	UIApplicationMain (in UIKit) + 1436
> 28	BlankAppUnifiedVS	0x226010	wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) + 268
> 29	BlankAppUnifiedVS	0x20ad90	UIKit_UIApplication_Main_string___intptr_intptr (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) + 48
> 30	BlankAppUnifiedVS	0x20ad50	UIKit_UIApplication_Main_string___string_string (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) + 200
> 31	BlankAppUnifiedVS	0x12dd3c	BlankAppUnifiedVS_Application_Main_string__ (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) + 44
> 32	BlankAppUnifiedVS	0x1c3e28	wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) + 196
> 33	BlankAppUnifiedVS	0x263478	mono_jit_runtime_invoke (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) (mini.c:6727)
> 34	BlankAppUnifiedVS	0x2aadf6	mono_runtime_invoke (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) (object.c:2831)
> 35	BlankAppUnifiedVS	0x2ae2e2	mono_runtime_exec_main (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) (object.c:4088)
> 36	BlankAppUnifiedVS	0x2ae120	mono_runtime_run_main (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) (object.c:3714)
> 37	BlankAppUnifiedVS	0x24d81c	mono_jit_exec (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) (driver.g.c:1009)
> 38	BlankAppUnifiedVS	0x30fe98	monotouch_main (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) (monotouch-main.m:450)
> 39	BlankAppUnifiedVS	0x2305e0	main (in aff1b90843a052c209c8933abce19be55f4880ecb2b7349061af4e353ad006e1) (main.armv7.m:39)
> 40	libdyld.dylib	0x328e0aac	start (in libdyld.dylib) + 0

## Expected result

The app should build and run without error on both 32-bit and 64-bit devices and simulators. If you build the app using Xamarin Studio on Mac, it behaves correctly.

## Additional information

The problem is caused by the `CGRect` input type that is passed into the `WKWebView()` constructor. If you manually invoke the corresponding `[WKWebView initWithFrame:configuration:]` selector, and pass in a `struct` that resembles `CGRect` but uses plain `float` fields instead of `nfloat` fields, then the crash does not occur.

## Version information

Xamarin (e78d10d6993f95fc3ebe791aeb4aacff165bf8bb)
Xamarin.Android (0ef616ae42005ece52f6df7aa1e093ceb11998f8)
Xamarin.iOS (209abebbd8f1a292d042420edb45fa5fbd3f017b)

Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.51641

### Mac build host

Xamarin.iOS (Business Edition)
Hash: 08968c4
Build date: 2014-10-20 21:48:06-0400

Mono 3.10.0 ((detached/e204655)
Xcode 6.1 (6604), Build 6A1052d
Mac OS X 10.9.5
Comment 1 Saurabh 2015-02-06 06:25:38 UTC
I have checked this Issue with latest builds and I am unable o reproduce this Issue with attached sample. application gets deployed and launched successfully on iPhone 5S 8.1 Simulator.

Application Output: https://gist.github.com/saurabh360/b2bba348c3e0573c261f
Xamarin Log: https://gist.github.com/saurabh360/551ad90587c283dbbc0c
Application Output: https://gist.github.com/saurabh360/29c3358285b08a086897
MTBServer Log: https://gist.github.com/saurabh360/65fdc13c73395927ec7a

Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.51641

Installed Version: Professional

LightSwitch for Visual Studio 2013   06177-004-0446016-02238
Microsoft LightSwitch for Visual Studio 2013

Team Explorer for Visual Studio 2013   06177-004-0446016-02238
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06177-004-0446016-02238
Microsoft Visual Basic 2013

Visual C# 2013   06177-004-0446016-02238
Microsoft Visual C# 2013

Visual C++ 2013   06177-004-0446016-02238
Microsoft Visual C++ 2013

Visual F# 2013   06177-004-0446016-02238
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker   06177-004-0446016-02238
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Windows Phone SDK 8.0 - ENU   06177-004-0446016-02238
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

ASP.NET and Web Tools   12.4.51016.0
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Microsoft Azure Websites
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Microsoft Azure

ASP.NET Web Frameworks and Tools 2012.2   4.1.21001.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.21010.0
For additional information, visit http://www.asp.net/

Common Azure Tools   1.3
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Microsoft Azure Mobile Services Tools   1.3
Microsoft Azure Mobile Services Tools

NuGet Package Manager   2.8.50926.663
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Office Developer Tools for Visual Studio 2013 ENU   12.0.30626
Microsoft Office Developer Tools for Visual Studio 2013 ENU

PowerShell Tools   1.3
Provides file classification services using PowerShell

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   12.0.41012.0
Microsoft SQL Server Data Tools

Windows Phone 8.1 SDK Integration   1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin (080a254)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android (49a04b966feb40dfdba49d57ba16249b66d606a6)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS (3b3ef438017c7ecf486defa9e01567a5f2b3cb2a)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified

@Brendan, Are you still getting this Issue with latest build?
Comment 2 Brendan Zagaeski (Xamarin Team, assistant) 2015-04-10 20:56:52 UTC
After double-checking the behavior of this bug, I'm satisfied that it is indeed a duplicate of bug 23868.

*** This bug has been marked as a duplicate of bug 23868 ***