[bcl] Add null reference checks to Interlocked.Exchange<T> (mono/mono#17400)
authorAleksey Kliger (λgeek) <alklig@microsoft.com>
Fri, 18 Oct 2019 23:11:22 +0000 (19:11 -0400)
committerZoltan Varga <vargaz@gmail.com>
Fri, 18 Oct 2019 23:11:22 +0000 (19:11 -0400)
commit3f9407696ebb34fd40548730e5eed184821919a9
treecb75d33773f5d4ca98f2f2304782d1258f4ac098
parent38bcec31fc537eca20e9240e7e5d4cca657ec219
[bcl] Add null reference checks to Interlocked.Exchange<T> (mono/mono#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

Commit migrated from https://github.com/mono/mono/commit/d8ae32a9ee7763c861bdc31831271d82aa8a4953
src/mono/netcore/System.Private.CoreLib/src/System.Threading/Interlocked.cs