Bug 13341 - Xamarin.IOS + ServiceStack JSON Serializer: Exception only on the device.
Summary: Xamarin.IOS + ServiceStack JSON Serializer: Exception only on the device.
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Pre-release ()
Version: 6.3.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Zoltan Varga
URL:
: 13506 ()
Depends on:
Blocks:
 
Reported: 2013-07-19 12:05 UTC by Grégory
Modified: 2016-05-24 19:30 UTC (History)
6 users (show)

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


Attachments
Solution to reproduce (711.98 KB, application/zip)
2013-07-19 12:05 UTC, Grégory
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 Grégory 2013-07-19 12:05:42 UTC
Created attachment 4383 [details]
Solution to reproduce

Xamarin Studio 4.0.10 (build 5)
Mono 3.1.2
Xamarin.iOS 6.3.8.11

Json Serialization (ServiceStack) works fine on the simulator but throw a NULL Exception on the device only.
Comment 1 Grégory 2013-07-19 12:35:04 UTC
Also, the bug occurs when i try to just serialize a Dictionnary.
Comment 2 Grégory 2013-07-22 09:09:23 UTC
It's just a limitation.
Comment 3 Sebastien Pouliot 2013-07-22 10:22:53 UTC
Most of the limitations on value-types were removed in 6.3.x so it might not be invalid.

The full exception is:

System.NullReferenceException: Object reference not set to an instance of an object
  at ServiceStack.Text.Common.ToStringDictionaryMethods`3[System.Int32,XamarinBug.CategoryStat,ServiceStack.Text.Json.JsonTypeSerializer].WriteGenericIDictionary (System.IO.TextWriter writer, IDictionary`2 map, ServiceStack.Text.Common.WriteObjectDelegate writeKeyFn, ServiceStack.Text.Common.WriteObjectDelegate writeValueFn) [0x00000] in <filename unknown>:0
  at at (wrapper unknown) object:gsharedvt_in ()
  at at (wrapper unknown) object:gsharedvt_out ()
  at ServiceStack.Text.Common.ToStringDictionaryMethods`3[System.Int32,XamarinBug.CategoryStat,ServiceStack.Text.Json.JsonTypeSerializer].WriteIDictionary (System.IO.TextWriter writer, System.Object oMap, ServiceStack.Text.Common.WriteObjectDelegate writeKeyFn, ServiceStack.Text.Common.WriteObjectDelegate writeValueFn) [0x00000] in <filename unknown>:0
  at at (wrapper delegate-invoke) <Module>:invoke_void__this___TextWriter_object_WriteObjectDelegate_WriteObjectDelegate (System.IO.TextWriter,object,ServiceStack.Text.Common.WriteObjectDelegate,ServiceStack.Text.Common.WriteObjectDelegate)
  at ServiceStack.Text.Common.JsWriter`1+<GetCoreWriteFn>c__AnonStorey22`1[ServiceStack.Text.Json.JsonTypeSerializer,System.Collections.Generic.Dictionary`2[System.Int32,XamarinBug.CategoryStat]].<>m__5B (System.IO.TextWriter w, System.Object x) [0x00000] in <filename unknown>:0
  at ServiceStack.Text.Common.WriteType`2[XamarinBug.Stats,ServiceStack.Text.Json.JsonTypeSerializer].WriteProperties (System.IO.TextWriter writer, System.Object value) [0x00000] in <filename unknown>:0
  at ServiceStack.Text.Common.WriteType`2[XamarinBug.Dummy,ServiceStack.Text.Json.JsonTypeSerializer].WriteProperties (System.IO.TextWriter writer, System.Object value) [0x00000] in <filename unknown>:0
  at ServiceStack.Text.JsonSerializer.SerializeToString (System.Object value, System.Type type) [0x00000] in <filename unknown>:0
  at XamarinBug.XamarinBugViewController.ViewDidLoad () [0x0000d] in /Users/sebastienpouliot/Downloads/XamarinBug/XamarinBug/XamarinBugViewController.cs:30
  at at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSend (intptr,intptr)
  at MonoTouch.UIKit.UIWindow.MakeKeyAndVisible () [0x00010] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIWindow.g.cs:129
  at XamarinBug.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary options) [0x00032] in /Users/sebastienpouliot/Downloads/XamarinBug/XamarinBug/AppDelegate.cs:31
  at at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
  at XamarinBug.Application.Main (System.String[] args) [0x00001] in /Users/sebastienpouliot/Downloads/XamarinBug/XamarinBug/Main.cs:17
Comment 4 Sebastien Pouliot 2013-07-22 10:27:18 UTC
Zoltan, with -gsharedvt=false we get the "old" ExecutionEngineException, otherwise this NRE (tested with 6.4, not master).
Comment 5 Zoltan Varga 2013-07-22 12:38:56 UTC
Its either a gsharedvt problem, or a bug in the app/class libs which didn't happen before because of the ExecutionEngineException.
Comment 6 Sebastien Pouliot 2013-07-22 13:26:10 UTC
It works fine with the simulator, so the library is unlikely to be the issue. 
Also the linker is disabled in both cases, nothing should be missing.
Comment 7 Zoltan Varga 2013-07-22 21:43:37 UTC
Fixed in mono-extensions f722a3141924c0dee906d2dc143905af338ad6e3.
Comment 8 Grégory 2013-07-23 08:59:48 UTC
Nice! Do you have any release date of this fix (n the alpha/beta channel ?

Thank you
Comment 9 Zoltan Varga 2013-07-23 10:19:55 UTC
Not yet.
Comment 10 Rolf Bjarne Kvinge [MSFT] 2013-07-30 06:49:06 UTC
*** Bug 13506 has been marked as a duplicate of this bug. ***
Comment 12 Mike James 2013-08-21 03:53:33 UTC
A customer is reporting that the issue is back in the latest Alpha release (6.4.1)
Comment 13 Zoltan Varga 2013-08-21 09:27:51 UTC
Which version is the customer using ? The latest x.ios version is 6.4.3, not 6.4.1.
Comment 14 Steve Meagher 2013-08-23 16:23:30 UTC
It was the latest beta version, not alpha.
Comment 15 Sebastien Pouliot 2013-08-23 16:32:03 UTC
The easiest way to get exact version information is to use the "Xamarin Studio" menu, "About Xamarin Studio" item, "Show Details" button and copy/paste the version informations (you can use the "Copy Information" button). 

That will give us something like comment #11 (and removes doubt and work duplication).
Comment 16 Steve Meagher 2013-08-23 17:18:29 UTC
I re-selected the beta version just now (have been using stable which does not exhibit the problem) and re-created the crash.

Here is the version information:

=== Xamarin Studio ===

Version 4.0.12 (build 3)
Installation UUID: 36f870a5-a2fe-447e-a8a6-ebf61bb1270e
Runtime:
	Mono 3.2.1 ((no/f3f789e)
	GTK 2.24.20
	GTK# (2.12.0.0)
	Package version: 302010001

=== Apple Developer Tools ===

Xcode 4.6.2 (2067.2)
Build 4H1003

=== Xamarin.iOS ===

Version: 6.4.3.0 (Business Edition)
Hash: 0068990
Branch: 
Build date: 2013-13-08 05:24:39-0400

=== Xamarin.Mac ===

Xamarin.Mac: Not Installed

=== Xamarin.Android ===

Version: 4.8.1 (Starter Edition)
Android SDK: /Users/sam/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0   (API level 14)
		4.0.3 (API level 15)
Java SDK: /usr
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06-451-11M4406)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01-451, mixed mode)

=== Build Information ===

Release ID: 400120003
Git revision: 593d7acb1cb78ceeeb482d5133cf1fe514467e39
Build date: 2013-08-07 20:30:53+0000
Xamarin addins: 25a0858b281923e666b09259ad4746b774e0a873

=== Operating System ===

Mac OS X 10.7.5
Darwin SM-MBP.local 11.4.2 Darwin Kernel Version 11.4.2
    Thu Aug 23 16:25:48 PDT 2012
    root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64
Comment 17 Zoltan Varga 2013-08-23 17:25:44 UTC
I cannot reproduce the problem using the original testcase in either debug or release mode.
Comment 18 Steve Meagher 2013-08-23 17:31:16 UTC
You're testing on the device (it works in the simulator)?
Comment 19 Steve Meagher 2013-08-23 17:33:01 UTC
Also, my bug was "Bug 13506 - Serializing and deserializing a Dictionary in latest beta" which was set to being a duplicate of this issue.  Maybe you could try the test case attached to 13506.
Comment 20 Zoltan Varga 2013-08-23 18:21:31 UTC
I can't reproduce using the testcase to 13506 either.
Comment 21 Steve Meagher 2013-08-28 00:21:06 UTC
My apologies for belaboring this point, but can you confirm that you tested the 13506 test case using the beta version on a device and not the simulator?

Also, I now get the error using the Stable channel as well as the beta channel.
Comment 22 Steve Meagher 2013-08-28 00:23:52 UTC
Also, can you suggest the best way of ensuring I have a clean version of xamarin to make sure the problem is not caused by my set-up?
Comment 23 Zoltan Varga 2013-08-29 16:32:03 UTC
Yes, it was tested on the device.
Comment 24 Zoltan Varga 2013-08-29 16:35:13 UTC
As for 13506, can you attach the complete test project which is failing ?

You can re-install xamarin by deleting /Developer/MonoTouch.
Comment 25 Steve Meagher 2013-08-29 17:19:57 UTC
I've attached the complete solution for the test case on 13506
Comment 26 Sebastien Pouliot 2016-05-24 19:30:04 UTC
It looks like the reference bug #13506 was closed after last comment.

If you are still experiencing this issue please provide all the requested information and re-open the bug report. Thanks!