You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 27, 2020. It is now read-only.
Currently, Rose compiles repetitions simply by unrolling them. For example, a{10} is compiled as the "match a" instruction repeated 10 times.
This can be dangerous. Consider what would happen if the user added a few more zeroes to the repeat count. Now, rather than allocating 10 instructions, the compiler will allocate 100 or 1000 or 100 000 instead. In fact, this is a case of exponential memory usage, since every extra digit multiplies the code size by 10.
There are two ways to solve this issue:
re2 -- place a hard limit on memory usage. If the compiler uses more than a specified amount (1 MB) it halts.
glennsl's engine -- rather than unrolling loops, track the repeat count in an extra register.
I prefer the re2 method, since it doesn't require changing the VM. The majority of repetitions are small anyway, so it's not worth gutting the implementation just to handle a corner case.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Currently, Rose compiles repetitions simply by unrolling them. For example,
a{10}
is compiled as the "matcha
" instruction repeated 10 times.This can be dangerous. Consider what would happen if the user added a few more zeroes to the repeat count. Now, rather than allocating 10 instructions, the compiler will allocate 100 or 1000 or 100 000 instead. In fact, this is a case of exponential memory usage, since every extra digit multiplies the code size by 10.
There are two ways to solve this issue:
I prefer the re2 method, since it doesn't require changing the VM. The majority of repetitions are small anyway, so it's not worth gutting the implementation just to handle a corner case.
The text was updated successfully, but these errors were encountered: