Skip to content

Commit d5aa75c

Browse files
Fix lifetime1 test (#55371)
The test assumed that a GC didn't occur between the last use of a variable and a check of a value set in the finalizer. This presumably worked up until now because the test is set to build in debuggable code mode. But R2R compilations ignore that and build with optimization enabled, and GCStress exposes the issue. Fix the test by explicitly marking a variable as KeepAlive until after the requisite check. Fixes #54042
1 parent b814a97 commit d5aa75c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/tests/JIT/Directed/lifetime/lifetime1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public static int f2()
5353
{
5454
A a = new A();
5555
a.F();
56-
a = null;
5756

5857
// Testcase 3
5958
Console.WriteLine();
@@ -63,6 +62,7 @@ public static int f2()
6362
Console.WriteLine("Testcase 3 FAILED");
6463
return -1;
6564
}
65+
GC.KeepAlive(a);
6666
return 100;
6767
}
6868

0 commit comments

Comments
 (0)