[sgen] Fix pointer access.

Thanks to @martinpotter for finding the bug.
[jit] Reduce code duplication in the inlining code.
[threaddpool] Fix deadlock in thread pool with monitor thread

Because the monitor thread was not marked as background thread, remove_and_abort_threads (threads.c:2807) would mark it as needed to be waited to shutdown the runtime, and wait_for_tids (threads.c:2652) would then wait indefinitely for it to finish. The issue was that the monitor was waiting on the semaphore monitor_sem, and thus would never exit.

Thread 7 (Thread 0x1c13 of process 99776):
#0  0x00007fff86590a56 in ?? () from /usr/lib/system/libsystem_kernel.dylib
#1  0x00000001003cc03a in mono_sem_wait (sem=0x1004f7f50, alertable=0) at mono-semaphore.c:103
#2  0x00000001002cef41 in monitor_thread (unused=0x0) at threadpool.c:898
#3  0x00000001002cb78f in start_wrapper_internal (data=0x10500abf0) at threads.c:657
#4  0x00000001002cb4a1 in start_wrapper (data=0x10500abf0) at threads.c:704
#5  0x00000001003d61d4 in inner_start_thread (arg=0x7fff5fbfe500) at mono-threads-posix.c:84
#6  0x00007fff8e7c9899 in _pthread_body () from /usr/lib/system/libsystem_pthread.dylib
#7  0x00007fff8e7c972a in _pthread_start () from /usr/lib/system/libsystem_pthread.dylib
#8  0x00007fff8e7cdfc9 in thread_start () from /usr/lib/system/libsystem_pthread.dylib
#9  0x0000000000000000 in ?? ()

Thread 1 (Thread 0x1503 of process 99776):
#0  0x00007fff86594716 in ?? () from /usr/lib/system/libsystem_kernel.dylib
#1  0x00007fff8e7cbc3b in _pthread_cond_wait () from /usr/lib/system/libsystem_pthread.dylib
#2  0x000000010039cfaa in _wapi_handle_timedwait_signal_handle (handle=0xa55, timeout=0x0, alertable=1, poll=0) at handles.c:1595
#3  0x000000010039d03d in _wapi_handle_wait_signal_handle (handle=0xa55, alertable=1) at handles.c:1540
#4  0x00000001003b7ba3 in WaitForSingleObjectEx (handle=0xa55, timeout=4294967295, alertable=1) at wait.c:194
#5  0x00000001003b865d in WaitForMultipleObjectsEx (numobjects=1, handles=0x7fff5fbff1f8, waitall=1, timeout=4294967295, alertable=1) at wait.c:516
#6  0x00000001002c75df in wait_for_tids (wait=0x7fff5fbff1f8, timeout=4294967295) at threads.c:2658
#7  0x00000001002c70e5 in mono_thread_manage () at threads.c:2951
#8  0x00000001000d551b in mono_main (argc=6, argv=0x7fff5fbff9e8) at driver.c:2021
#9  0x0000000100001bd1 in mono_main_with_options (argc=6, argv=0x7fff5fbff9e8) at ./main.c:91
#10 0x00000001000017d3 in main (argc=6, argv=0x7fff5fbff9e8) at ./main.c:122
[tests] Add tests for Bug #23058 and polymorphism/known types in DataContractJsonSerializer.
[bcl] Implement KnownTypes for DataContractJsonSerializer. Fixes #23058 and polymorphism support.
Also discarded old __type hint behavior in JsonSerializationReader that potentially allowed any loaded type to be instantiated.
[jit] Clean up the jit failure handling code a bit, move the the bulk of the eror handling macros into functions, unify the cleanup code at the end of mono_method_to_ir ().
[jit] Extract the ctor calling code from the NEWOBJ implementation into a separate function.
Test that BlockingCollection.Add blocks when there is no more space.
BlockingCollection.Add was adding one more item than it should.
Test BlockCollection.AddAny. Covers #22775.
Improved BlockingCollection.AddAny. Fixes #22775.
AddAny no longer consumes OperationCanceledException.
AddAny no longer blocks while adding an item to the first collection when its full.
Refactored AddToAny and TakeFromAny to reuse code.
[threaddpool] Fix deadlock in thread pool with monitor thread (2nd attempt)

Because the monitor thread was not marked as background thread, remove_and_abort_threads (threads.c:2807) would mark it as needed to be waited to shutdown the runtime, and wait_for_tids (threads.c:2652) would then wait indefinitely for it to finish. The issue was that the monitor was waiting on the semaphore monitor_sem, and thus would never exit.

Thread 7 (Thread 0x1c13 of process 99776):
#0  0x00007fff86590a56 in ?? () from /usr/lib/system/libsystem_kernel.dylib
#1  0x00000001003cc03a in mono_sem_wait (sem=0x1004f7f50, alertable=0) at mono-semaphore.c:103
#2  0x00000001002cef41 in monitor_thread (unused=0x0) at threadpool.c:898
#3  0x00000001002cb78f in start_wrapper_internal (data=0x10500abf0) at threads.c:657
#4  0x00000001002cb4a1 in start_wrapper (data=0x10500abf0) at threads.c:704
#5  0x00000001003d61d4 in inner_start_thread (arg=0x7fff5fbfe500) at mono-threads-posix.c:84
#6  0x00007fff8e7c9899 in _pthread_body () from /usr/lib/system/libsystem_pthread.dylib
#7  0x00007fff8e7c972a in _pthread_start () from /usr/lib/system/libsystem_pthread.dylib
#8  0x00007fff8e7cdfc9 in thread_start () from /usr/lib/system/libsystem_pthread.dylib
#9  0x0000000000000000 in ?? ()

Thread 1 (Thread 0x1503 of process 99776):
#0  0x00007fff86594716 in ?? () from /usr/lib/system/libsystem_kernel.dylib
#1  0x00007fff8e7cbc3b in _pthread_cond_wait () from /usr/lib/system/libsystem_pthread.dylib
#2  0x000000010039cfaa in _wapi_handle_timedwait_signal_handle (handle=0xa55, timeout=0x0, alertable=1, poll=0) at handles.c:1595
#3  0x000000010039d03d in _wapi_handle_wait_signal_handle (handle=0xa55, alertable=1) at handles.c:1540
#4  0x00000001003b7ba3 in WaitForSingleObjectEx (handle=0xa55, timeout=4294967295, alertable=1) at wait.c:194
#5  0x00000001003b865d in WaitForMultipleObjectsEx (numobjects=1, handles=0x7fff5fbff1f8, waitall=1, timeout=4294967295, alertable=1) at wait.c:516
#6  0x00000001002c75df in wait_for_tids (wait=0x7fff5fbff1f8, timeout=4294967295) at threads.c:2658
#7  0x00000001002c70e5 in mono_thread_manage () at threads.c:2951
#8  0x00000001000d551b in mono_main (argc=6, argv=0x7fff5fbff9e8) at driver.c:2021
#9  0x0000000100001bd1 in mono_main_with_options (argc=6, argv=0x7fff5fbff9e8) at ./main.c:91
#10 0x00000001000017d3 in main (argc=6, argv=0x7fff5fbff9e8) at ./main.c:122

Thanks @akoeplinger for the help debugging
Merge pull request #1330 from esdrubal/blockingcollection

Improved BlockingCollection.AddAny.
[bcl] Free strings allocated using Marshal.SecureStringToBSTR () using Marshal.ZeroFreeBSTR ().
[bcl] Use List instead of ArrayList () in a few places.
Fix oops in DataContractJsonSerializer fix
[runtime] Use the functionality in mono-proclib.c to enumerate processes, remove duplicate code from the io-layer.
[runtime] Use the functionality in mono-proclib.c to get the current pid, remove duplicate code from the io-layer.
[runtime] Remove pre WinXP SP2 windows support code.