[runtime] MonoIO methods using SafeHandle now prevent handle reuse.
commitcfbd2c797b1438a4f88310a5669c54760d570424
authorMarcos Henrich <marcos.henrich@xamarin.com>
Thu, 29 Jan 2015 14:31:26 +0000 (29 14:31 +0000)
committerMarcos Henrich <marcos.henrich@xamarin.com>
Thu, 29 Jan 2015 15:27:57 +0000 (29 15:27 +0000)
tree17ed2dab067fc9ab87705454c76fe20a702a71b4
parent4f2b974bfa83bc792a2943fffd944501b8d242bb
[runtime] MonoIO methods using SafeHandle now prevent handle reuse.

This reverts partially commit 753229c72dd9f2b63beb097700e350164b887c2.

Marshallers are not called for ICalls parameters so the change of ICalls parameters to SafeHandle did not prevents handle reuse.

To prevent handle reuse ICalls are no longer called directly.
Instead we call a method that receives a SafeHandle and wraps the ICall call with safeHandle.DangerousAddRef and safeHandle.DangerousReleaseRef.

This guarantees that the safe handle reference countererence does not reach zero before or while the ICall, thus avoiding the handle beeing released and possibly reused.
mcs/class/corlib/System.IO/MonoIO.cs
mcs/class/corlib/System/Environment.cs
mono/metadata/appdomain.c
mono/metadata/file-io.c
mono/metadata/file-io.h
mono/metadata/icall-def.h