Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Problem when method returns Regexp capture group using special variable $1 #5503
Initially we found the problem using Jruby 220.127.116.11, but it's also actual in 18.104.22.168 and in the latest version.
Other relevant info you may wish to add:
After some iterations returned result always is
Full console output:
This is a problem in IR when adding frame push/pop instructions. The pop is happening before the value has been captured, so it ends up nil (or actually, it gets whatever the next-highest heap frame has for
From the IR along the "then" path for the if:
referenced this issue
Dec 10, 2018
Pushed a PR that should fix this. I have not written a test yet.
I do not know when this change was introduced, but it might never have worked right in the optimized "call protocol" execution modes. The problem was that frame-local implicit variables like $~ and $_ were not captured (in some circumstances) before the frame got popped, resulting in reading those values from a previous frame when they were returned. Only "binding" variables (those stored on the heap in DynamicScope instances) were safely captured before pop.
@subbuss Can you review my patch? I already merged it since I'm pretty sure it's correct, but you originally removed the
This will add an additional Copy instruction to all returns of a non-temp or literal from a method with a heap frame. I'm not sure how much of an impact this really is, since most non-trivial data loads go immediately into a temp variable.