Add regression test for ValueTuple StackOverflow in large Dictionary initializers#121120
Add regression test for ValueTuple StackOverflow in large Dictionary initializers#121120
Conversation
…tHub #17455) Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
|
@copilot, this addresses #8980 not dotnet/roslyn#17455 (the latter was already closed) |
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Updated in commit 732bca3. Renamed test from GitHub_17455 to Runtime_8980 and changed issue reference to #8980. |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
|
@copilot The test should not be catching exceptions. Instead, it should leave the exception unhandled. It provides better diagnostic experience. |
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR adds a regression test for a JIT stack overflow issue that occurred when using large Dictionary initializers with ValueTuple values. The test validates that the JIT can properly handle dictionary initialization with 5000 ValueTuple entries without causing a StackOverflowException.
Key changes:
- Added new regression test Runtime_8980 with large Dictionary initializer containing 5000 ValueTuple entries
- Configured project to disable XUnit wrapper generator to prevent source generation stack overflow
|
/azp run runtime-coreclr outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run runtime-coreclr outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run runtime-coreclr outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/ba-g infrastructure timeouts |
Fix test build with `BuildAllTestsAsStandalone`, regression after #121120 Fixed similar to `src/tests/JIT/Regression/JitBlue/GitHub_10215/GitHub_10215.cs`
Regression test for ValueTuple Dictionary StackOverflow issue
The test verifies that large Dictionary collection initializers with ValueTuple values don't cause StackOverflowException. The issue was caused by excessive JIT-created temporary structs on the stack. With 5000 entries, this test validates the JIT optimizations that were implemented to fix this issue.
The test only verifies the dictionary count to avoid floating-point equality issues, as the primary purpose is to ensure the code doesn't overflow the stack during compilation/execution.
Original prompt
This section details on the original issue you should resolve
<issue_title>System.ValueTuple causes a StackOverflow when used in a large Dictionary.</issue_title>
<issue_description>Moved (and edited) this issue from the roslyn repo.
Summary: you add an empty
Mainmethod to the attached code, then compile it withcsc.exe geocoords_stackoverflow.cs.txt. When you run the resulting executable, you get an overflow error (Process is terminated due to StackOverflowException.)From discussion with @VSadov, we think this is a JIT issue rather than a compiler issue.
FYI @jkotas for triage. Thanks
@andras-ferencz commented on Tue Feb 28 2017
When using the new System.ValueTuple in a large Dictionary, I receive a stack overflow exception where as I do not with System.Tuple.
Dictionary<int, (double lat, double lon)> zipcodes = new Dictionary<int, (double lat, double lon)>() {{123,(18.180555,-66.749961)} };works fine just for reference.geocoords_stackoverflow.cs.txt
geocoords_worksfine.cs.txt
@jcouv commented on Tue Feb 28 2017
I'm able to see the repro file. The code causing stack overflow looks like this:
@jcouv commented on Wed Sep 20 2017
I'm able to repro this. The program compiles fine, but it overflows when run.
The strange thing is that decompiling the static constructor shows that it only expects to use very little IL stack (
.maxstack 4from debug compilation):