Bug 49806 - TaskScheduler.UnobservedTaskException not called when an exception occurs in a Task.Run
Summary: TaskScheduler.UnobservedTaskException not called when an exception occurs in ...
Status: RESOLVED NORESPONSE
Alias: None
Product: Runtime
Classification: Mono
Component: GC (show other bugs)
Version: 4.6.0 (C8)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-12-13 12:01 UTC by softlion
Modified: 2017-10-11 17:44 UTC (History)
7 users (show)

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


Attachments

Description softlion 2016-12-13 12:01:06 UTC
TaskScheduler.UnobservedTaskException not called when an exception occurs in a Task.Run

Repro:
https://forums.xamarin.com/discussion/14530/taskscheduler-unobservedtaskexception-not-called

  TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;

 Task.Run(() =>
        {
              throw new Exception("bug");
        }

  private void TaskSchedulerOnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs unobservedTaskExceptionEventArgs)
    {
         Log.Error("wsm","TaskScheduler.UnobservedTaskException from {0}: {1}", s.GetType(), e.Exception);
    }


Version:

Microsoft Visual Studio Professional 2015
Version 14.0.25431.01 Update 3
Microsoft .NET Framework
Version 4.6.02006

Installed Version: Professional

Xamarin   4.3.0.458 (e738933)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   7.1.0.13 (72366f7)
Visual Studio extension to enable development for Xamarin.Android.

Xamarin.iOS   10.4.0.33 (d93ae7e)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 1 softlion 2016-12-13 12:01:56 UTC
Note that the Task.Run code is in a pcl library. Don't know if it is important to note.
Comment 2 Marek Safar 2016-12-15 17:42:40 UTC
Could you attach the app it reproduce the issue? I guess this is Android issue?

This looks like GC issue because all the logic is driven by Finalizer, see https://github.com/mono/mono/blob/af10ff717e227acc2c41a4dd82b435afa52e5936/mcs/class/referencesource/mscorlib/system/threading/Tasks/TaskExceptionHolder.cs#L101
Comment 3 softlion 2016-12-15 18:19:42 UTC
Yes it's on Android. I've not checked yet on iOS but there was an issue too. I'll try a repro.
Comment 4 Rodrigo Kumpera 2017-10-11 17:44:45 UTC
We have not received the requested information. If you are still experiencing this issue please provide all the requested information and reopen the bug report.

Thank you!

Note You need to log in before you can comment on or make changes to this bug.