Bug 40724 - [Foundation] NSObject.AddObserver throws NRE if observer callback is null
Summary: [Foundation] NSObject.AddObserver throws NRE if observer callback is null
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: master
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: 10.0.0 (C8)
Assignee: Oleg Demchenko
Depends on:
Reported: 2016-04-27 03:45 UTC by Oleg Demchenko
Modified: 2016-06-10 17:22 UTC (History)
4 users (show)

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

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 Oleg Demchenko 2016-04-27 03:45:24 UTC
Currently NSObject throws NullReferenceException on first call to observer if callback provided by user is null.

We should check observer parameter in NSObject.AddObserver method. Probably throw argument exception if is observer is null is a good solution.
Comment 1 Sebastien Pouliot 2016-05-01 14:36:48 UTC
https://github.com/xamarin/xamarin-macios/pull/7 merged
Comment 2 Rajneesh Kumar 2016-05-03 11:55:53 UTC
I have checked this issue with the following build from master:


I observed that this issue has been fixed in master build, now NSObject throws System.ArgumentNullException on first call to observer if callback provided by user is null and this is expected behavior.

Screencast: http://www.screencast.com/t/0p8iEqXTf

However this issue doesn't seems fixed in Cycle 7 build:

Here now NSObject throws System.NullReferenceException

Screencast: http://www.screencast.com/t/5ffaiLOVnnnZ

So this issue doesn't fixed in cycle 7, hence I am reopening this issue.

Environment Info: https://gist.github.com/Rajneesh360Logica/c0d70b16f58f88f708631e145e426ae9

Comment 3 Oleg Demchenko 2016-05-03 19:06:58 UTC
Moving target milestone for this bug for C8 since it's not a regression, it was not filed by a customer and it was filed late in the cycle.
Comment 4 Parmendra Kumar 2016-06-06 18:16:57 UTC
I have checked this issue with latest Master build and observed that this issue is working fine.

Screencast: http://www.screencast.com/t/4yHrWIRf7C

I will Verify this issue with C8 build.

Xamarin Studio Enterprise  6.1 (build 4412)
Mono 4.5.2 (master/79451d2) (64-bit)
Xamarin.Profiler : 0.32.99
Xcode 7.2 (9548)
Xamarin.iOS: (Xamarin Enterprise)
Xamarin.Android : (Xamarin Enterprise)
Mac OS X 10.10.5
Comment 5 Parmendra Kumar 2016-06-10 17:22:16 UTC
As per comment #4 marking this issue Verified fixed.