[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [PATCH] Loop Overflow Bug Fix and Tests (FINAL)
- From: Russell Haley <russ.haley@...>
- Date: Fri, 17 Nov 2017 00:09:26 -0800
On Thu, Nov 16, 2017 at 2:45 PM, Paige DePol <firstname.lastname@example.org> wrote:
> Thanks to the help of Roberto and others I am posting what should now be the
> definitive patch for correcting and detecting loop overflow edge cases when
> using very large integers and/or floating point values.
> This will correctly allow the use of math.mininteger and math.maxinteger as
> either the starting or ending values for loops as well as correctly stepping
> to those values without causing an integer overflow.
> The only difference between this patch and the one previously posted was the
> quick addition of a simple magnitude check for floating-point loops. If the
> provided step value is unable to modify either the loop starting value or
> the loop limit value an error will be thrown indicting the step value
> magnitude is too small. This will prevent infinite loops from occurring.
> Hopefully this patch will be useful to some, I will be incorporating it into
> my custom version of Lua... hopefully these changes can make it into the
> official Lua release as well to make loops in Lua a bit more robust! :)
> I am also attaching an updated version of the test file (loopfix-test.lua)
> to adjust for the new step magnitude checks!
> I created another benchmark, this time iterating through both decimal and
> floating-point loops... in a release build. The difference is even more
> negligible than the previous tests!
> Vanilla Lua ran the benchmark in 19.4039 seconds.
> Patched Lua ran the benchmark in 19.4354 seconds.
> The difference between Vanilla and Patched Lua is 0.0315 seconds... which
> is considerably faster than the 0.66 seconds from the previous benchmark!
Nice work Paige. I'll get a port update ready for FreeBSD just in case. :)