Bug 42222 - System.Threading.Tasks.Task causes app crash on older devices
Summary: System.Threading.Tasks.Task causes app crash on older devices
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Marek Habersack
URL:
Depends on:
Blocks:
 
Reported: 2016-06-28 21:14 UTC by cschulte
Modified: 2016-09-01 12:00 UTC (History)
2 users (show)

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


Attachments
Sample project to reproduce the bug (18.14 KB, application/x-zip-compressed)
2016-06-29 16:34 UTC, cschulte
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 FIXED

Description cschulte 2016-06-28 21:14:09 UTC
If you try to use the class System.Threading.Tasks.Task on API 15 or lower, then the app will either crash or work incorrectly.

Example:

Create blank Xamarin Android sample app.

Add this code inside button click event:

Task.Factory.StartNew(() =>
{
   //Pretend like we're doing something important here
});


This will cause the app to crash on API 15 emulator.
Comment 1 Marek Habersack 2016-06-29 15:49:14 UTC
Please provide the full crash info and, preferably, a small and ready to build+run sample which reproduces the crash. Also, please tell us which version of Xamarin.Android do you see this with, whether the crash is happening on device or in emulators (and what is the emulator/device architecture). Thanks!
Comment 2 cschulte 2016-06-29 16:34:57 UTC
Created attachment 16524 [details]
Sample project to reproduce the bug

Steps to reproduce the bug:

1.  Run the sample project on an API level 15 emulator
2.  Once the app starts click the button
3.  Clicking the button triggers a Task to start, which causes the app to crash
Comment 3 cschulte 2016-06-29 16:35:33 UTC
Ok, additional information below....

---------------------------

This bug is occurring on latest stable version of Xamarin Android.  I tried downgrading to Xamarin version 4.0.1.145 but the bug exists there too.

The crash is happening on an Intel Atom (x86) API level 15 emulator.  I don't have a real device running API level 15 but I would assume the bug exists on a real device too.

I've attached a sample project for reproducing the bug.  To reproduce the bug, follow these steps:

1.  Run the sample project on an API level 15 emulator
2.  Once the app starts click the button
3.  Clicking the button triggers a Task to start, which causes the app to crash

---------------------------

Below is the only information that's available when the crash occurs (pulled from LogCat):

06-29 16:11:17.931 D/Mono    ( 1709): [0x9bd2a98] worker starting
06-29 16:11:17.931 E/mono-rt ( 1709): Stacktrace:
06-29 16:11:17.931 E/mono-rt ( 1709): 
06-29 16:11:17.931 E/mono-rt ( 1709): 
06-29 16:11:17.931 E/mono-rt ( 1709): Attempting native Android stacktrace:
06-29 16:11:17.931 E/mono-rt ( 1709): 
06-29 16:11:17.931 E/mono-rt ( 1709): 	Could not unwind with `libunwind.so`: Cannot load library: load_library[1091]: Library '/data/data/TaskBug.TaskBug/lib/libunwind.so' not found
06-29 16:11:17.931 E/mono-rt ( 1709): 	Could not unwind with `libcorkscrew.so`: Cannot load library: load_library[1091]: Library '/data/data/TaskBug.TaskBug/lib/libcorkscrew.so' not found
06-29 16:11:17.931 E/mono-rt ( 1709): 
06-29 16:11:17.931 E/mono-rt ( 1709): 	No options left to get a native stacktrace :-(
06-29 16:11:17.931 E/mono-rt ( 1709): 
06-29 16:11:17.931 E/mono-rt ( 1709): =================================================================
06-29 16:11:17.931 E/mono-rt ( 1709): Got a SIGSEGV while executing native code. This usually indicates
06-29 16:11:17.931 E/mono-rt ( 1709): a fatal error in the mono runtime or one of the native libraries 
06-29 16:11:17.931 E/mono-rt ( 1709): used by your application.
06-29 16:11:17.931 E/mono-rt ( 1709): =================================================================
06-29 16:11:17.931 E/mono-rt ( 1709): 
06-29 16:11:17.931 F/libc    ( 1709): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=128)
06-29 16:11:18.141 I/DEBUG   (  774): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
06-29 16:11:18.141 I/DEBUG   (  774): Build fingerprint: 'unknown'
06-29 16:11:18.141 I/DEBUG   (  774): pid: 1709, tid: 1729  >>> TaskBug.TaskBug <<<
06-29 16:11:18.141 I/DEBUG   (  774): signal 11 (SIGSEGV), code 128 (?), fault addr 00000000
06-29 16:11:19.111 I/BootReceiver(  869): Copying /data/tombstones/tombstone_04 to DropBox (SYSTEM_TOMBSTONE)
06-29 16:11:19.120 D/dalvikvm(  869): GC_FOR_ALLOC freed 633K, 14% free 11323K/13063K, paused 5ms
06-29 16:11:19.120 D/Zygote  (  777): Process 1709 terminated by signal (11)
06-29 16:11:19.120 W/InputDispatcher(  869): channel 'b5d28e30 TaskBug.TaskBug/md525f57aa323783dbf08a6a22760af0cfc.MainActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x8
06-29 16:11:19.120 E/InputDispatcher(  869): channel 'b5d28e30 TaskBug.TaskBug/md525f57aa323783dbf08a6a22760af0cfc.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
06-29 16:11:19.141 D/dalvikvm(  869): GC_CONCURRENT freed 177K, 11% free 11721K/13063K, paused 1ms+0ms
06-29 16:11:19.141 I/WindowManager(  869): WIN DEATH: Window{b5d28e30 TaskBug.TaskBug/md525f57aa323783dbf08a6a22760af0cfc.MainActivity paused=false}
06-29 16:11:19.141 W/InputDispatcher(  869): Attempted to unregister already unregistered input channel 'b5d28e30 TaskBug.TaskBug/md525f57aa323783dbf08a6a22760af0cfc.MainActivity (server)'
06-29 16:11:19.141 I/ActivityManager(  869): Process TaskBug.TaskBug (pid 1709) has died.
06-29 16:11:19.141 W/ActivityManager(  869): Force removing ActivityRecord{b5c23db0 TaskBug.TaskBug/md525f57aa323783dbf08a6a22760af0cfc.MainActivity}: app died, no saved state
06-29 16:11:19.150 W/NetworkManagementSocketTagger(  869): setKernelCountSet(10045, 0) failed with errno -2
06-29 16:11:19.150 W/NetworkManagementSocketTagger(  869): setKernelCountSet(10004, 1) failed with errno -2
06-29 16:11:19.171 W/InputManagerService(  869): Got RemoteException sending setActive(false) notification to pid 1709 uid 10045
06-29 16:11:19.171 I/WindowManager(  869): WINDOW DIED Window{b5d28e30 TaskBug.TaskBug/md525f57aa323783dbf08a6a22760af0cfc.MainActivity paused=false}
Comment 4 Marek Habersack 2016-09-01 12:00:16 UTC
The issue no longer exists with the current versions of XA from master and cycle8 branches (https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-builds-master/ and https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-builds-cycle8/, respectively)