Bug 39020 - InvalidCastException on ArmV7
Summary: InvalidCastException on ArmV7
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: iOS
Classification: Xamarin
Component: Mono runtime / AOT compiler ()
Version: XI 9.4 (iOS 9.2)
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Zoltan Varga
URL:
Depends on:
Blocks:
 
Reported: 2016-02-22 21:19 UTC by Grigory (Playtika)
Modified: 2017-02-14 02:26 UTC (History)
3 users (show)

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


Attachments
Attempted confirmation test case (that has not shown the crash so far) (13.06 KB, application/zip)
2017-02-14 02:26 UTC, Brendan Zagaeski (Xamarin Team, assistant)
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 NOT_REPRODUCIBLE

Description Grigory (Playtika) 2016-02-22 21:19:17 UTC
Hi

Only Armv7 devices. 
120 crashes on 1.5 million DAU. No repro project/cases/steps.


System.InvalidCastException: Specified cast is not valid.
  at (wrapper castclass) System.Object:__castclass_with_cache (object,intptr,intptr) (code.cs:1)
  at Monosyne.WeakEventHandler`3[S,C,T].OnEvent (Monosyne.T param) <0x65660d + 0x00032> in <filename unknown>:0  (code.cs:1)


public abstract class WeakEventHandlerBase<S>
    {
        private WeakReference obj;
        private S source;

        public WeakEventHandlerBase(S source, Object obj)
        {
            this.source = source;
            this.obj = new WeakReference(obj);
        }

        public WeakReference WeakReference
        {
            get{ return obj;}
        }

        public S Source
        {
            get{ return source;}
        }
    }

public class WeakEventHandler<S, C, T>:  WeakEventHandlerBase<S>
    {
        private Action<S, Action<T>> unsubscribe;
        private Action<C, T> action;
        
        public WeakEventHandler(S source, C obj, Action<C, T> action, Action<S, Action<T>> unsub)
            : base(source, obj)
        {
            this.unsubscribe = unsub;
            this.action = action;
        }
        
        public void OnEvent(T param)
        {
            Object target = WeakReference.Target;
            if (target != null)
            {
                action((C)target, param);
            } else
            {
                unsubscribe(Source, OnEvent);
            }
        }

        public static implicit operator Action<T>(WeakEventHandler<S, C, T> handler)
        {
            return handler.OnEvent;
        }
    }
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2017-02-14 02:26:10 UTC
Created attachment 19808 [details]
Attempted confirmation test case (that has not shown the crash so far)

## Non-engineering team bug backlog confirmation testing

I will pick up on this old bug briefly for a confirmation attempt with recent Xamarin versions to help work through the bug backlog.




## Confirmation steps attempted for the provided test code

1. Placed the test code from Comment 0 into a sample app (attached) that uses the `implicit operator` to perform a cast.

2. Ran the test app locally on an iPhone 4, iOS 7.1.2 (armv7) device.

3. Ran the test app on Xamarin Test Cloud across 21 armv7 and armv7s devices (iPad 2, iPhone 4s, iPod touch 5th gen., iPhone 5C).



### Testing results: no crashes

The attempted confirmation strategy did not reveal any crashes.

(Xamarin Test Cloud results viewable here: https://testcloud.xamarin.com/test/com-example-genericsactioncast_912f55a9-eae8-4e0d-b2f9-851d77cfa255/)




## Bug status update: resolving as not reproducible for now

Based on (a) the absence of crashes in the confirmation attempt, (b) the possibility that the original detected crashes in Comment 0 might or might not have been intermittent on the problematic devices, and (c) the relatively large number of changes in the Mono runtime since the original filing date of this bug, I will mark the bug as not reproducible at this time.

That said, if the company from Comment 0 still has incoming user analytics that show that this issue is present in recent versions of Xamarin, please do file a new bug report with a refresh for the latest details about it.  Thanks in advance!




## Additional testing environment info

Xamarin.iOS 9.8.2.22 (cycle7-sr1: f37444a)
Mono 4.4.2 (mono-4.4.0-branch-c7sr1/f72fe45) (64-bit)

Xcode 7.3 (10183.3), Build 7D175
Mac OS 10.11.6

US English locale, US eastern time zone