Fix for potential bad tailcall code generation #1298
Conversation
Nice work tracking this down! :) |
Seems this is the same as in #1289 from TFS that was later rolled back? |
Yeah, looks like it. Why did it get rolled back? |
@masonwheeler Not quite sure, but here it is again :) |
Maybe we could ask @sivarv? :) |
Should we include the regression test here or in a followup PR? |
@mmdriley I've managed to narrow down a regression test, I'll have that included in the merge tomorrow morning :) |
Wow you guys still haven't figured out why the bug is there, and why the fix was rolled back previously...? |
@danielgindi it looks like @sivarv wanted to fix dotnet/fsharp#536 (comment), but it wasn't the correct fix for that so I assume he rolled it back. |
@forki Thanks for your response :-) Btw, I love it that Microsoft has moved to Git! |
Thanks! |
I was just thinking, how come this didn't show up in the tests? It seems like this would blow up everywhere. |
Nope. This blows up in production environment only, and only where there are function call which are the last statement in a function, and only when the optimizer decides to... |
This would imply the tests are either not run in "production environment" (meaning "Release" mode with "Optimize code" enabled) or there is no such test that would trigger the tail call opt. |
Or this case is such an edge case that one of the test just doesn't trigger it. They probably have added a test case now to their internal tests that hits this edge case. (Atleast I hope so ;)) |
The JIT can potentially pass an incorrect parameter to a callee when optimizing a tail call. While updating a GT_LCL* node with lcl var num of temp passed to the tail call, we also need to change its opererand to GT_LCL_VAR.
Hey all, sorry for the delay in response. I have added the test case along with the fix. The reason that the original fix was backed was for a few reasons:
@richlander has posted a nice blog about the issue over at the MSDN dotnet blog: http://blogs.msdn.com/b/dotnet/archive/2015/07/28/ryujit-bug-advisory-in-the-net-framework-4-6.aspx |
Thank you @mmitche. |
Fix for potential bad tailcall code generation
The JIT can potentially pass an incorrect parameter to a callee when optimizing a tail call. While updating a GT_LCL* node with lcl var num of temp passed to the tail call, we also need to change its opererand to GT_LCL_VAR.
Fixes #1296