diff options
author | noahfalk <noahfalk@microsoft.com> | 2017-09-14 19:33:29 -0700 |
---|---|---|
committer | noahfalk <noahfalk@microsoft.com> | 2017-09-15 13:28:37 -0700 |
commit | 0b5e12c59d37778d98156ae19298b2152b886c6d (patch) | |
tree | c27f78b922cfa0b06301dd2fcdeb1a136a552f2e /tests | |
parent | f3dfbf546396db24f5fbc690213e89beaebd5f35 (diff) | |
download | coreclr-0b5e12c59d37778d98156ae19298b2152b886c6d.tar.gz coreclr-0b5e12c59d37778d98156ae19298b2152b886c6d.tar.bz2 coreclr-0b5e12c59d37778d98156ae19298b2152b886c6d.zip |
Fix test StackCommitCommon
This test will hang if run with non-optimized jitted code because it takes a dependency on exactly when locally allocated objects go out of scope. Although I doubt CLI spec guarantees the new code will always work either, it does work with the runtime/JIT as currently implemented.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/baseservices/threading/commitstackonlyasneeded/StackCommitCommon.cs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/src/baseservices/threading/commitstackonlyasneeded/StackCommitCommon.cs b/tests/src/baseservices/threading/commitstackonlyasneeded/StackCommitCommon.cs index fef88b1306..d97f9c2d8e 100644 --- a/tests/src/baseservices/threading/commitstackonlyasneeded/StackCommitCommon.cs +++ b/tests/src/baseservices/threading/commitstackonlyasneeded/StackCommitCommon.cs @@ -236,9 +236,19 @@ namespace StackCommitTest public static void Run(Action action) { - new Finalizer(action); + //We need to allocate the object inside of a seperate method to ensure that + //the reference will be eliminated before GC.Collect is called. Technically + //even across methods we probably don't make any formal guarantees but this + //is sufficient for current runtime implementations. + CreateUnreferencedObject(action); GC.Collect(); GC.WaitForPendingFinalizers(); } + + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + private static void CreateUnreferencedObject(Action action) + { + new Finalizer(action); + } } -}
\ No newline at end of file +} |