[bcl] Add null reference checks to Interlocked.Exchange<T> (#17400)
commitd8ae32a9ee7763c861bdc31831271d82aa8a4953
authorAleksey Kliger (λgeek) <alklig@microsoft.com>
Fri, 18 Oct 2019 23:11:22 +0000 (18 19:11 -0400)
committerZoltan Varga <vargaz@gmail.com>
Fri, 18 Oct 2019 23:11:22 +0000 (18 19:11 -0400)
tree30d4e3a87dc621d2f7adc767b0dbe825d469ab04
parenta2992d634b9cfa6ae8572ba597f009cb05104743
[bcl] Add null reference checks to Interlocked.Exchange<T> (#17400)

* [bcl] Add null reference checks to Interlocked.Exchange<T>

and Interlocked.CompareExchange<T>

This is to mimic the old behavior in unmanaged when the intrinsic cannot be
used.

The issue was detected via the coreclr acceptance test:
https://github.com/mono/coreclr/blob/mono/tests/src/baseservices/threading/interlocked/exchange/exchangetneg.il

* and netcore
mcs/class/corlib/System.Threading/Interlocked.cs
netcore/System.Private.CoreLib/src/System.Threading/Interlocked.cs