Bug 2871 - Random Crash while making an in-app purchase using StoreKit
Summary: Random Crash while making an in-app purchase using StoreKit
Status: RESOLVED NORESPONSE
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 5.0
Hardware: Macintosh Mac OS
: High normal
Target Milestone: 7.2.0 (iOS 7.1)
Assignee: Rolf Bjarne Kvinge [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2012-01-12 15:53 UTC by Joe Wilcox
Modified: 2015-04-16 10:17 UTC (History)
9 users (show)

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

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 NORESPONSE

Description Joe Wilcox 2012-01-12 15:53:12 UTC
I'm getting a random crashes while trying to make purchases via storekit.  This one occurs every now and then before the purchase starts.  I'm also seeing a crash after the purchase returns. 

This is with 5.0.4.

Here is the output:

Stacktrace:

  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr (intptr,intptr,intptr) <IL 0x00025, 0xffffffff>
  at MonoTouch.StoreKit.SKPaymentQueue.AddPayment (MonoTouch.StoreKit.SKPayment) [0x0001c] in /Developer/MonoTouch/Source/monotouch/src/StoreKit/SKPaymentQueue.g.cs:88
  at SuicideKings2.InAppPurchaseManager.MakePurchase (string) [0x0000e] in /Users/buckaroo/SourceCode/SuicideKings2/SuicideKings2/InAppPurchaseManager.cs:194
  at SuicideKings2.uiBuyChips.MakePurchase (int) [0x0005d] in /Users/buckaroo/SourceCode/SuicideKings2/SuicideKings2/Menus/uiBuyChips.cs:445
  at SuicideKings2.uiBuyChips.ProcessTouch (zGame.GameTouch) [0x000b8] in /Users/buckaroo/SourceCode/SuicideKings2/SuicideKings2/Menus/uiBuyChips.cs:365
  at zGame.MenuStack.ProcessTouch (zGame.GameTouch) [0x0003a] in /Users/buckaroo/SourceCode/zGame/zGame/MenuStack.cs:167
  at zGame.BaseGame.ProcessInput () [0x00145] in /Users/buckaroo/SourceCode/zGame/zGame/BaseGame.cs:597
  at zGame.BaseGame.Update (Microsoft.Xna.Framework.GameTime) [0x0015a] in /Users/buckaroo/SourceCode/zGame/zGame/BaseGame.cs:505
  at Microsoft.Xna.Framework.Game.DoUpdate (Microsoft.Xna.Framework.GameTime) [0x0000b] in /Users/buckaroo/SourceCode/MonoGame/MonoGame.Framework/iOS/Game.cs:307
  at Microsoft.Xna.Framework.GameWindow.OnUpdateFrame (OpenTK.FrameEventArgs) [0x00044] in /Users/buckaroo/SourceCode/MonoGame/MonoGame.Framework/iOS/IOSGameWindow.cs:376
  at OpenTK.Platform.iPhoneOS.iPhoneOSGameView.RunIteration () [0x00049] in /Developer/MonoTouch/Source/monotouch/src/OpenGLES/OpenTK/Platform/iPhoneOS/iPhoneOSGameView.cs:746
  at MonoTouch.Foundation.NSActionDispatcher.Apply () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/shared/Foundation/NSAction.cs:45
  at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) <IL 0x0004e, 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 SuicideKings2.Program.Main (string[]) [0x00000] in /Users/buckaroo/SourceCode/SuicideKings2/SuicideKings2/Program.cs:27
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

Native stacktrace:

	0   SuicideKings2                       0x000e1008 mono_handle_native_sigsegv + 408
	1   SuicideKings2                       0x00011c7f mono_sigsegv_signal_handler + 351
	2   libsystem_c.dylib                   0x904ee59b _sigtramp + 43
	3   ???                                 0xffffffff 0x0 + 4294967295
	4   CoreFoundation                      0x01208ae9 CFArrayApplyFunction + 57
	5   StoreKit                            0x0221fcc8 -[SKPaymentQueue _notifyObserversAboutChanges:] + 152
	6   StoreKit                            0x0221f90f -[SKPaymentQueue _addLocalTransactionForPayment:] + 289
	7   StoreKit                            0x0221ebc0 -[SKPaymentQueue addPayment:] + 483
	8   ???                                 0x119abab4 0x0 + 295353012
	9   ???                                 0x16db3e94 0x0 + 383467156
	10  ???                                 0x16db3a78 0x0 + 383466104
	11  ???                                 0x16db3990 0x0 + 383465872
	12  ???                                 0x16db2840 0x0 + 383461440
	13  ???                                 0x164f3219 0x0 + 374288921
	14  ???                                 0x125b8564 0x0 + 307987812
	15  ???                                 0x125b5a00 0x0 + 307976704
	16  ???                                 0x125b5427 0x0 + 307975207
	17  ???                                 0x125b4f94 0x0 + 307974036
	18  ???                                 0x125b4608 0x0 + 307971592
	19  ???                                 0x125b4398 0x0 + 307970968
	20  ???                                 0x09f60138 0x0 + 167117112
	21  SuicideKings2                       0x000119cf mono_jit_runtime_invoke + 1407
	22  SuicideKings2                       0x0022014a mono_runtime_invoke + 170
	23  SuicideKings2                       0x002ee515 monotouch_trampoline + 3381
	24  Foundation                          0x01863ec6 __NSFireTimer + 113
	25  CoreFoundation                      0x012ab966 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
	26  CoreFoundation                      0x012ab407 __CFRunLoopDoTimer + 551
	27  CoreFoundation                      0x0120e7c0 __CFRunLoopRun + 1888
	28  CoreFoundation                      0x0120ddb4 CFRunLoopRunSpecific + 212
	29  CoreFoundation                      0x0120dccb CFRunLoopRunInMode + 123
	30  GraphicsServices                    0x0489f879 GSEventRunModal + 207
	31  GraphicsServices                    0x0489f93e GSEventRun + 114
	32  UIKit                               0x022a6a9b UIApplicationMain + 1175
	33  ???                                 0x0e2f4995 0x0 + 237980053
	34  ???                                 0x0e2f3178 0x0 + 237973880
	35  ???                                 0x0e2f2e70 0x0 + 237973104
	36  ???                                 0x0e2f2fc6 0x0 + 237973446
	37  SuicideKings2                       0x000119cf mono_jit_runtime_invoke + 1407
	38  SuicideKings2                       0x0022014a mono_runtime_invoke + 170
	39  SuicideKings2                       0x00222e81 mono_runtime_exec_main + 705
	40  SuicideKings2                       0x00222091 mono_runtime_run_main + 929
	41  SuicideKings2                       0x000ad5bf mono_jit_exec + 239
	42  SuicideKings2                       0x002f41aa main + 5194
	43  SuicideKings2                       0x00003035 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 Joe Wilcox 2012-01-12 15:53:55 UTC
-- NOTE This crash occurred in the simulator.
Comment 2 Sebastien Pouliot 2012-01-12 17:46:05 UTC
    4   CoreFoundation                      0x01208ae9 CFArrayApplyFunction +
57
    5   StoreKit                            0x0221fcc8 -[SKPaymentQueue
_notifyObserversAboutChanges:] + 152
    6   StoreKit                            0x0221f90f -[SKPaymentQueue
_addLocalTransactionForPayment:] + 289
    7   StoreKit                            0x0221ebc0 -[SKPaymentQueue
addPayment:] + 483

^ this happens deep inside StoreKit. Looks like an observer is null (maybe it was collected by the GC ?) which leads to your crash. Can you provide us (mark it private if required) with the code you're using before calling AddPayment ?
Comment 5 Joe Wilcox 2012-01-12 23:53:34 UTC
I've added some of the source.  The UIPage that holds the instance and my version of the InAppPurchaseManager adapted from the code by Clancey.
Comment 7 Sebastien Pouliot 2012-01-13 15:20:38 UTC
c.c. Clancey
Comment 8 Miguel de Icaza [MSFT] 2013-02-11 22:10:35 UTC
This is over a year old, has this been fixed?
Comment 9 Grégory 2013-04-11 06:59:52 UTC
Same bug
Comment 10 chad 2013-06-20 16:27:53 UTC
Same thing for me with 6.0.6
Comment 12 Gleb 2013-07-31 11:37:19 UTC
Same for me.
Comment 13 PJ 2013-11-19 16:44:42 UTC
This bug was targeted for a past milestone, moving to the next non-hotfix active milestone.
Comment 14 Rolf Bjarne Kvinge [MSFT] 2013-12-05 17:08:25 UTC
It looks like StoreKit is trying to post a notification to an object that has been freed.

From the stack trace that seems to be a SKPaymentTransactionObserver (or subclass) - so can you verify this by adding logging to any SKPaymentTransactionObserver subclasses and see if that's the case?

private class MySKPaymentObserver : SKPaymentTransactionObserver
{
	private InAppPurchaseManager IAPManager;

	public MySKPaymentObserver ()
	{
		Console.WriteLine ("MySKPaymentObserver");
	}

	~MySKPaymentObserver ()
	{
		Console.WriteLine ("~MySKPaymentObserver");
	}

	protected override void Dispose (bool disposing)
	{
		Console.WriteLine ("~MySKPaymentObserver");
	}

        /* your code */
}
Comment 15 Rolf Bjarne Kvinge [MSFT] 2015-04-16 10:17:57 UTC
This bug has been waiting for information for over a year; I'm going to close it, if it still occurs to anybody please try the suggestion in comment #14 and reopen the bug with the results.