Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
Created attachment 3918 [details]
Test Case Which Crashes on Android up to and including API 14 (4.0)
When a GC occurs on Android versions less than 4.1, there is a chance that the garbage collector will corrupt native memory if there are pending async callbacks. It seems as if something about the pending Task or some of the hoisted variable references are not being handled correctly, leading to miscollection, and then corruption.
I originally noticed this error doing some complicated things involving chattering between C# and a WebView. Generally, the corruption manifested as A SIGSEGV with no C# stack trace. However, it occasionally give a much stranger result, such as a NullReferenceException in code that clearly couldn't have produced one, or a NRE inside the generated Java<=>C# binding code.
I was able to make a relatively simple test case to produce the error. The key part of the code is as follows:
for (int i = 0; i < 10; ++i)
await Task.Run(() => GC.Collect());
When I rewrote the test case to eliminate all use of the async and await keywords, I was able to run without seeing a crash, presumably confirming that this is an issue at the cross-section of GC+async.
The attached test case was evaluated on these platform
* On Galaxy Nexus, 4.2 - works as expected
* On emux86 4.1 - works as expected
* On mono-api-14-arm - dies
* On Atrix, 2.3 - dies
* On emux86, 2.3 - dies
* On mono-api-10-arm - dies
Created attachment 3919 [details]
Test Case Rewritten to avoid async/await and only use TPL (
As I mentioned before, I ran a version of this case where the async/await functionality was not used.
On my Android 2.3 (Atrix) device, it hung after running for some time and then upon reopening the app, it SIGSEGVed. This behavior was observed on multiple long runs.
On the API-10 emulator, it still seems to be working after 30 min.
On the 2.3-x86 emulator, it still seems to be working after 15 min (note that it took longer to repro the crash on this emulator with the first test case).
I'm seeing Attachment #3919 [details] hang on a Nexus 10 w/ 126.96.36.1997139499.
I can't repro with 4.7.4 on a Galaxy Note. Now trying 188.8.131.52.
I can repro it with 4.7.5.
Fixed on master. Will be part of 4.7.6.
Today we have checked this issue on following builds :
XS 4.0.9 (build 12)
Devices info :
Samsung S2 (2.3.2)
Samsung S2 (4.1.2)
HTC One (4.0.3)
We have tried this with attachment given in comment 1 or comment 2( attachment 3919 [details]). Application deploy successfully and relaunch in loop.
Hence closing this issue. Changing its status to verified