Random Xamarin crash / ios7 / StoreKit - xamarin.ios

We are currently facing a very annoying critical random crash with our in-app purchases process.
Random because only some customers encounter this issue.
The crash suddenly appears with ios7 release (before ios7 RTM, no crash reports were received). So we suppose it is related to a change in StoreKit behavior.
It seems that we have an issue when we call the transaction.OriginalTransaction
Do other Xamarin users are facing the same issue?
Searching Xamarin forum / Google and so on, we have found that our issue could perhaps be related to this bug we found here https://bugzilla.xamarin.com/show_bug.cgi?id=2871#c13
Does someone found a workaround to this random bug ?
More generally (without Xamarin/Monotouch involved), is someone facing a similar issue with ios7 and storekit?
We are using :
Xamarin Studio 4.2.1 (build 1)
Xamarin.iOS 7.0.4.209
Mono 3.2.4
Xcode 4.6.3
Here is our code for the UpdatedTransactions method:
public override void UpdatedTransactions(SKPaymentQueue queue, SKPaymentTransaction[] transactions)
{
List<SKPaymentTransaction> chartTransactions = new List<SKPaymentTransaction>();
foreach (SKPaymentTransaction transaction in transactions)
{
string productId = transaction.TransactionState == SKPaymentTransactionState.Restored ? transaction.OriginalTransaction.Payment.ProductIdentifier : transaction.Payment.ProductIdentifier;
if (string.IsNullOrEmpty(_ProductIdPrefix) == false && productId.StartsWith(_ProductIdPrefix, true, CultureInfo.InvariantCulture))
{
chartTransactions.Add(transaction);
}
}
_PaymentTransactionChangedCallback(chartTransactions.ToArray());
}
Here is the re-symbolicated crash log (we have resymbolized many customers crash-log with the same call stack) :
...
(not re-symbolized)
...
mono_handle_native_sigsegv (in OurAppMono) (mini-exceptions.c:2325)
sigabrt_signal_handler (in OurAppMono) (mini-posix.c:196)
...
(not re-symbolized)
...
monotouch_unhandled_exception_handler (in OurAppMono) (monotouch-glue.m:1440)
mono_invoke_unhandled_exception_hook (in OurAppMono) (mini-exceptions.c:2561)
mono_thread_abort (in OurAppMono) (mini.c:2629)
mono_handle_exception_internal (in OurAppMono) + 2136
mono_handle_exception (in OurAppMono) (mini-exceptions.c:1902)
handle_signal_exception (in OurAppMono) (exceptions-arm.c:559)
<--
MonoTouch_StoreKit_SKPaymentTransaction_get_OriginalTransaction (in OurAppMono) + 48
-->
wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr (in OurAppMono) + 196
mono_jit_runtime_invoke (in OurAppMono) (mini.c:5793)
mono_runtime_invoke (in OurAppMono) (object.c:2790)
native_to_managed_trampoline_OurApp_ChartsServer_IOSChartPaymentObserver_UpdatedTransactions (in OurAppMono) (<stdin>:1214)
...
(not re-symbolized)
...
wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr (in OurAppMono) + 236
OurAppMono_Application_Main_string__ (in OurAppMono) + 164
wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr (in OurAppMono) + 196
mono_jit_runtime_invoke (in OurAppMono) (mini.c:5793)
mono_runtime_invoke (in OurAppMono) (object.c:2790)
mono_runtime_exec_main (in OurAppMono) (object.c:3972)
mono_runtime_run_main (in OurAppMono) (object.c:3602)
mono_jit_exec (in OurAppMono) (driver.c:1125)
main (in OurAppMono) (main.m:482)
Edit:
the crash seems to be linked to ios7.
(not related with Xamarin).
The solution is to handle (productid = nil) returned by the AppStore and to Finish matching transactions.
Cf.:
Following in app purchase, app crashing on startup. productIdentifier=nil?
In App Purchase (IAP) process appears to be crashing the app on launch for one of my users

I do not think this is related to bug #2871, but I believe it is instead a NullReferenceException inside the OriginalTransaction getter (or around where you call the OriginalTransaction getter - exact location might be a bit off due to optimizations).
The app is crashing because you're not handling the exception - I suggest you add exception handling to your UpdateTransaction method, and handle the exception somehow (send a log back to yourself for instance, error message to the user and/or try again, etc.)

Related

An item with the same key has already been added error in ASP.NET MVC 5

I'm upgrading an ASP.NET MVC 3 project to MVC 5 (VS 2017) and i have the below line of code
IEnumerable<Country> countrydata = _db.Country.OrderBy(s => s.CountryName).ToList();
That line of code works fine in MVC 3 (in a .NET 4 project) but throws the below error in MVC 5 project targeting .NET 4.6.1, does anybody see why?
An item with the same key has already been added
UPDATE:
After further testing, it seems like all such calls to the database will fail in MVC 5 / Entity Framework 6, because even the below line fails with the same error message.
IEnumerable<AuthenticationType> authenticationProvider = _db.AuthenticationType.OrderBy(n => uthenticationProvider).ToList();
#Christos, see the .edmx designer message i mention below
Below is the stack trace
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at System.Data.Metadata.Edm.ObjectItemAttributeAssemblyLoader.LoadRelationshipTypes() at System.Data.Metadata.Edm.ObjectItemAttributeAssemblyLoader.LoadTypesFromAssembly() at System.Data.Metadata.Edm.ObjectItemAssemblyLoader.Load() at System.Data.Metadata.Edm.ObjectItemAttributeAssemblyLoader.Load() at System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, ObjectItemLoadingSessionData loadingData) at System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, KnownAssembliesSet knownAssemblies, EdmItemCollection edmItemCollection, Action1 logLoadMessage, Object& loaderCookie, Dictionary2& typesInLoading, List1& errors) at System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage) at System.Data.Metadata.Edm.ObjectItemCollection.ImplicitLoadAssemblyForType(Type type, EdmItemCollection edmItemCollection) at System.Data.Metadata.Edm.MetadataWorkspace.ImplicitLoadAssemblyForType(Type type, Assembly callingAssembly) at System.Data.Objects.ObjectContext.GetTypeUsage(Type entityCLRType) at System.Data.Objects.ObjectContext.GetEntitySetForNameAndType(String entitySetName, Type entityCLRType, String exceptionParameterName) at System.Data.Objects.ObjectContext.CreateObjectSet[TEntity](String entitySetName) at SSAMapper.Models.SSAMapperEntities.get_Country() in D:\Projects\SSAMapper\Models\SSAMapper.Designer.cs:line 240 at SSAMapper.Models.AdminModel.GetCountries(Boolean status, Boolean userCountry, Boolean loadDeactivatedCountry) in D:\Projects\SSAMapper\Models\AdminModel.cs:line 1116
I'm leaning towards it being the upgrade to Entity Framework 6 gone awry. It's using lazy loading, and you've removed .ToList() so the exception is thrown prior to any data access. We can see in the stack trace it's during creation of the ObjectSet<TEntity> and if I'm understanding it correctly, it looks to be when looking at relationships to make sure the assembly for their types are loaded.
I would look at the <NavigationProperty>s on the conceptual model in the .edmx and see if there appears to be any duplicates. It seems like it could also happen if you have duplicated model classes in your project or if any of the model classes are defined in more than one assembly in your bin (like if you renamed your project/target assembly but the original dll is still there).
Here are a couple links that may be useful: Upgrading to Entity Framework 6 I would go through that and make sure nothing was missed. And here was a question with the same error with the source code involved shown.

DLL_PROCESS_DETACH only one thread remaining

--- symptoms
When i load my Dll from a subthread of the host app and host app closes, only 1 thread remains when Dll_PROCESS_DETACH called. This is bad. It causes memory leaks and the required cleanup can't be done.
When i load my Dll from MAIN thread of the host app and host app closes,
all threads created in Dll are still running when Dll_PROCESS_DETACH called.
This is good, because i can do all the cleanup work required.
My Dll_PROCESS_ATTACH contains NO code. No thread is created, no API function called.
-- purpose of this Dll, use case
I need a Dll which can run in various host apps where i do not know when
exactly my Dll is loaded and unloaded.
Some of those host appls obviously
load my Dll from within a thread, e.g. this thread is running a script and the script uses exported functions of my Dll.
The general problem is: When the Dll is first loaded from a subthread of host app, it is not unloaded properly, because all threads seemed to be removed when Dll_PROCESS_DETACH called. This just not only causes memory leaks, also it can't do some internal clean up work, stopping threads and doing a final socket connection, used to communicate with a server.
All this works fine, when the Dll is loaded from a main thread (in my test host) or in specific host apps it tested.
Two stack traces of debug sessions of the c++ Dll running in Visual Studio 17.
First is the bad one, where the Dll is loaded froma subthread.
The 2nd is the good one, where the Dll been loaded from main thread.
// exit stack Dll Dll loaded in subthread ; breakpoint in `Dll_PROCESS_DETACH` This is BAD
DllTest.dll!DllTest_app::~DllTest_app() Line 176 C++
[External Code]
DllTest.dll!DllTest_app::destroy() Line 208 C++
DllTest.dll!DllMain(HINSTANCE__ * hModule, unsigned long ul_reason_for_call, void * lpReserved) Line 43 C++
[External Code]
DllTest_test.exe!exit_or_terminate_process(const unsigned int return_code) Line 130 C++
DllTest_test.exe!common_exit(const int return_code, const _crt_exit_cleanup_mode cleanup_mode, const _crt_exit_return_mode return_mode) Line 271 C++
DllTest_test.exe!exit(int return_code) Line 283 C++
[External Code]
// exit stack Dll loaded in mainthread; breakpoint in `Dll_PROCESS_DETACH` This is GOOD
DllTest.dll!DllTest_app::~DllTest_app() Line 175 C++
[External Code]
DllTest.dll!DllTest_app::destroy() Line 208 C++
DllTest.dll!DllMain(HINSTANCE__ * hModule, unsigned long ul_reason_for_call, void * lpReserved) Line 43 C++
[External Code]
DllTest_test.exe!DllTestWrap::Unload(int code, int bdeleteerror) Line 139 C++
DllTest_test.exe!DllTestWrap::~DllTestWrap() Line 66 C++
[External Code]
DllTest_test.exe!_execute_onexit_table::__l22::<lambda>() Line 198 C++
DllTest_test.exe!__crt_seh_guarded_call<int>::operator()<void <lambda>(void),int <lambda>(void) & __ptr64,void <lambda>(void) >(__acrt_lock_and_call::__l3::void <lambda>(void) && setup, _execute_onexit_table::__l22::int <lambda>(void) & action, __acrt_lock_and_call::__l4::void <lambda>(void) && cleanup) Line 199 C++
DllTest_test.exe!__acrt_lock_and_call<int <lambda>(void) >(const __acrt_lock_id lock_id, _execute_onexit_table::__l22::int <lambda>(void) && action) Line 882 C++
DllTest_test.exe!_execute_onexit_table(_onexit_table_t * table) Line 222 C++
DllTest_test.exe!common_exit(const int return_code, const _crt_exit_cleanup_mode cleanup_mode, const _crt_exit_return_mode return_mode) Line 211 C++
DllTest_test.exe!exit(int return_code) Line 283 C++
[External Code]
How to accomplish, that on Dll_PROCESS_DETACH called, all threads created in Dll still running and not terminated, regardless, if Dll is loaded from subthread or mainthread of host app.
Is there something that can be done by compiler- or linker settings, or a workaround ?
Thank you in advance for each hint.
It seems like one of the threads in your app calls exit() which leads to calling ExitProcess() API - https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-exitprocess
As documented in ExitProcess documentation, it terminates all threads and then calls DllMain() with DLL_PROCESS_DETACH.
Calling ExitProcess can also lead to a deadlock, if the terminated threads hold a mutex which the last thread executing DLL_PROCESS_DETACH tries to acquire.

Crash related to UITableViewController / UISearchDisplayController in MonoTouch/Xamarin.iOS

I'm having problem to find the cause of random crashes in my app. The crashes only occurs when I build in release mode and run on a device like iPhone or iPad. Running in debug on simulator no crashes occurs. My guess is that the problem has something to do with these two lines in the crash log,
6 UIKit 0x34a193d0 -[UISearchDisplayController _destroyManagedTableView] + 68
7 UIKit 0x34a2195a -[UISearchDisplayController dealloc] + 94
I've uploaded the source code of my UITableViewController and the full crash log here, https://gist.github.com/Nordis/6128735
All help to track the cause of the crashes is much appreciated!
Update
I've now crated a bug report, I looked and the thread Rolf suggested in the comments. So I downloaded the test case, applied the fix. But still exactly the same crash and the stack trace is very similar to what mine looks like.
https://bugzilla.xamarin.com/show_bug.cgi?id=13703
The solution provided by Rolf at Xamarin was fairly simple, all I had to do was to move the code from Dispose() to ViewDidDisappear() in my UITableViewController,
public override void ViewDidDisappear (bool animated)
{
searchController.SearchResultsSource = null;
searchController.Delegate = null;
base.ViewDidDisappear (animated);
}

Projection, Queries missing in Orchard 1.4.2

I can't see the queries section the dashboard, neither can I see that as a part of Projection Page.
Has anything changed?
In logs, there is one error :
Object reference not set to an instance of an object.
at Szmyd.Orchard.Modules.Menu.Drivers.BreadcrumbsPartDriver.<>c__DisplayClass5.<Display>b__4()
at Orchard.ContentManagement.Drivers.ContentPartDriver`1.<>c__DisplayClassd.<ContentShape>b__c(BuildShapeContext ctx) in C:\OrchardWebsite\src\Orchard\ContentManagement\Drivers\ContentPartDriver.cs:line 108
at Orchard.ContentManagement.Drivers.ContentPartDriver`1.<>c__DisplayClass13.<ContentShapeImplementation>b__12(BuildShapeContext ctx) in C:\OrchardWebsite\src\Orchard\ContentManagement\Drivers\ContentPartDriver.cs:line 116
at Orchard.ContentManagement.Drivers.ContentShapeResult.ApplyImplementation(BuildShapeContext context, String displayType) in C:\OrchardWebsite\src\Orchard\ContentManagement\Drivers\ContentShapeResult.cs:line 37
at Orchard.ContentManagement.Drivers.ContentShapeResult.Apply(BuildDisplayContext context) in C:\OrchardWebsite\src\Orchard\ContentManagement\Drivers\ContentShapeResult.cs:line 21
at Orchard.ContentManagement.Drivers.Coordinators.ContentPartDriverCoordinator.<>c__DisplayClassa.<BuildDisplay>b__9(IContentPartDriver driver) in C:\OrchardWebsite\src\Orchard\ContentManagement\Drivers\Coordinators\ContentPartDriverCoordinator.cs:line 49
at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\OrchardWebsite\src\Orchard\InvokeExtensions.cs:line
I had the same issue and found out the projector module was disabled. I don't know why it was disabled but it made sense enabling it.
No, it's still there. Something else must be going on, such as a version mismatch causing an exception when loading the module. Did you check your app_data\logs folder?
I had the same issue with Queries not showing up in the Dashboard. Disabling the Autoroute module and enabling it again worked for me.

SWT GTK 64 bit and UBUNTU 11.04 NPE

I'm currently working in an SWT standalone application. We usually work with windows but I'd like to work in Ubuntu.I set up the following environment.
Ubuntu 11.04 64bit
Java 6 update 27 64 bit
Eclipse Java EE 3.5 Galileo 64 bit
I'm using SWT GTK 64 bit
I've got a few classes extending different SWT widgets.
For example
public class MyCombo extends Combo implements CellEditor<Long> {
private Set<ListenerRef> listeners = new HashSet<ListenerRef>();
#Override
public void addListener(int eventType, Listener listener) {
listeners.add(new MyCombo.ListenerRef(eventType, listener));
super.addListener(eventType, listener);
}
#Override
protected void checkSubclass() {
// Do nothing
}
.
.
.
This code works perfectly well in Windows 7 64 bit, running SWT32 bit and java32 bit, from eclipse 32 bit.
In Ubuntu 11.04 I get a NPE (NullPointerException) when trying to add a listener, it seems that the listeners set is null, but it shouldn't cause that set should be initialized as for the code above, and as I say it works in Windows 7
First I had problems running the SWT 32 bit app in Ubuntu64 bit cause there's seem to be a bug when running 32 apps in 64 ubuntu, so I tried to run it with the 64 version, and now I'm getting this error. If I avoid this NPE checking the set, I end up getting a
java.lang.NullPointerException
at org.eclipse.swt.accessibility.Accessible.isValidThread(Unknown Source)
at org.eclipse.swt.accessibility.Accessible.checkWidget(Unknown Source)
at org.eclipse.swt.accessibility.Accessible.addRelation(Unknown Source)
Any ideas of what could be the reason? Are you aware of this problem in previous Ubuntu distrubutions? I don't get this problems in Windows 7, at least running SWT 32 bit
Please let me know if you need more details
Thanks and regards
BTW I forgot, SWT is 3.7 in Linux and 3.6.2 in Windows

Resources