Bug 5174 - GC.WaitForPendingFinalizers() freezes app in RELEASE builds. Sample project attached
Summary: GC.WaitForPendingFinalizers() freezes app in RELEASE builds. Sample project a...
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 5.2
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-05-18 12:34 UTC by René Ruppert
Modified: 2012-05-18 17:24 UTC (History)
3 users (show)

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

Project demonstrating the issue (5.87 KB, application/zip)
2012-05-18 12:34 UTC, René Ruppert

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:

Description René Ruppert 2012-05-18 12:34:11 UTC
Created attachment 1918 [details]
Project demonstrating the issue

MonoTouch 5.2.11, iPad 2 (5.1.1), ARM7 build, SGen ON

When calling GC.WaitForPendingFinalizers() the app freezes in RELEASE builds.
Please treat this prio 1 because our customers are cursing at us due to our application getting stuck randomly (if GC is triggered by the runtime).

Run the attached sample on an iPad 2 and watch the console output. It will show "1" and "2" but "3" is never outputted. "3" would be after WaitForPendingFinalizers().

What I noticed:

* Happens on the device only
* RELEASE builds only
* If I tick "emmit debug information" in the release build, it will also work
Comment 1 René Ruppert 2012-05-18 12:35:50 UTC
And one more note: if I kill the app forcefully on the iPad using home button double click and then restart it, it won't even show "1" and "2" but instead:

May 18 18:34:39 unknown SpringBoard[52] <Warning>: gctest failed to resume in time
May 18 18:34:39 unknown SpringBoard[52] <Warning>: Forcing crash report of GCTest[545]...
May 18 18:34:39 unknown SpringBoard[52] <Warning>: Finished crash reporting.
May 18 18:34:39 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:gctest[0x9069]) Exited: Killed: 9
May 18 18:34:39 unknown SpringBoard[52] <Warning>: Application 'GCTest' exited abnormally with signal 9: Killed: 9
May 18 18:34:39 unknown ReportCrash[547] <Notice>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/GCTest_2012-05-18-183439_iPad-von-Rene.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0

To me this means that even though it gets killed and exits, something is still running, maybe the GC.
Comment 2 René Ruppert 2012-05-18 12:45:52 UTC
And just to point that out: the app also freezes if DON'T call GC manually. I have reports about the exact same behavior that I'm getting if calling it manually. So I assume that at some point GC is simply triggered and freezes.
Comment 4 Rodrigo Kumpera 2012-05-18 17:24:38 UTC
Fixed on trunk. Will be part of 5.4.