Created attachment 2251 [details]
Test project to reproduce the bug
See the attachment, it's a simple MonoTouch project that reproduces the bug. Steps to reproduce:
1) Start the app
2) Press the button
3) Press the back button to navigate back
4) Repeat steps 2 and 3 until the crash occurs (usually in 5-15 seconds)
The first view controller creates a new instance of the ChildView controller every time the button is pressed (step 2). The old instance of the ChildView is nulled, so it can be garbage collected, since it is not anymore used by iOS. However, it seems that iOS keeps a reference to the old ChildView instances, because when a 'didReceiveMemoryWarning' is simulated in AppDelegate.cs, the app crashes since the managed ChildView instances have already been GC'ed.
See the following discussion on Stackoverflow: http://stackoverflow.com/questions/11609353/release-dispose-of-a-uiviewcontroller-in-monotouch
This actually looks like a GC (boehm) bug, it's not handling resurrecting weakrefs properly.
Sgen seems to work just fine.
Rodrigo, it looks like the gc clears out the target for resurrecting weakrefs before the dtor is called, so our intptr-nsobject mapping doesn't quite work as expected.
This is easy to duplicate (less than 30 secs) on 5.2.x but I could not duplicate it (after a few mins) on master. Boehm used in both cases.
5.2-series does not have the MonoTouch_Disposer IntPtr->NSObject fix.
nm comment #2, testing an (unrelated) mtouch fix using the same solution just crashed it
Anybody knows if this is related to the critical update announced on August 13 on http://blog.xamarin.com ? The description there sounds like it could be related.
Jonas, No this is not related. The next MonoTouch release (5.3.6) will provide more information on this issue (i.e. a more complete exception message) to ease finding where those comes from.
Thank you Sebastien!
We have posted an update that could help in this situation, would you be so kind to download the binaries in this page (it contains a description of the changes) and report whether this solves the problem?
Opening the hidden comment, to expand testing.
The fix has been back ported to 2.10. It's now a matter of landing it to a stable product.
Notice (2018-05-21): bugzilla.xamarin.com will be
switching to read-only mode on Thursday, 2018-05-25 22:00 UTC.
Please join us on
Visual Studio Developer Community and
GitHub to continue tracking
issues. Bugzilla will remain available for reference in read-only mode.
We will continue to work on open Bugzilla bugs and copy them to the new
locations as needed for follow-up. The See Also field
on each Bugzilla bug will be updated with a link to its new location
After Bugzilla is read-only, if you have new information to add for a
bug that does not yet have a matching issue on Developer Community or
GitHub, you can create a follow-up issue in the new location. Copy and
paste the title and description from this bug, and then add your new
details. You can get a pre-formatted version of the title and
In special cases you might also want the comments:
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.