Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuring Regexp stack limits #157

Closed
josh opened this issue Apr 2, 2015 · 4 comments
Closed

Configuring Regexp stack limits #157

josh opened this issue Apr 2, 2015 · 4 comments
Milestone

Comments

@josh
Copy link

josh commented Apr 2, 2015

Hey @svaarala,

Hit an issue trying to get some code to compile within the CoffeeScript compiler within duktape (again, 😉).

I narrowed it down pretty far this time. And of course was Regexp related.

/^(?:[^\\"#]|\\[\s\S]|"(?!"")|\#(?!\{))*/.exec("form[data-remote] input[type=submit],\nform[data-remote] button[type=submit],\nform[data-remote] button:not([type]),\nform[data-remote-submit] input[type=submit],\nform[data-remote-submit] button[type=submit],\nform[data-remote-submit] button:not([type])\n\"\"\"")
duk> /^(?:[^\\"#]|\\[\s\S]|"(?!"")|\#(?!\{))*/.exec("form[data-remote] input[type=submit],\nform[data-remote] button[type=submit],\nform[data-remote] button:not([type]),\nform[data-remote-submit] input[type=submit],\nform[data-remote-submit] button[type=submit],\nform[data-remote-submit] button:not([type])\n\"\"\"")
RangeError: regexp executor recursion limit
    duk_regexp_executor.c:145
    exec  native strict preventsyield
    global input:1 preventsyield

It seemed like this specific example was just a few iterations over the 1000 deep stack limit for DUK_RE_EXECUTE_RECURSION_LIMIT. I only had to bump it up to 1006 and it started working.

Do you think this default limit is to small for the deep stack mode? Or is this something we can make easier to configure via a compile time flag?

Thanks!

@svaarala
Copy link
Owner

svaarala commented Apr 2, 2015

It should be easy to make configurable - I can address it as part of #64 for example.

Probably the better fix would be to make the Regexp engine pluggable (#74). The built-in engine is a pretty minimal implementation because of footprint restrictions, and does backtracking through the C stack which is a limiting factor for large inputs.

@svaarala svaarala added this to the v1.2.0 milestone Apr 2, 2015
@svaarala
Copy link
Owner

svaarala commented Apr 4, 2015

Bumped regexp stack depth from 1000 to 10000 for the 1.2.0 release.

In 1.3.0 this should be addressed by adding a DUK_USE_xxx option for the stack limits so that they're configurable from duk_config.h (one can then e.g. use sed/awk/patch to replace values).

@svaarala svaarala modified the milestones: v1.3.0, v1.2.0 Apr 4, 2015
@josh
Copy link
Author

josh commented Apr 5, 2015

Works for me, thanks again @svaarala!

@josh josh closed this as completed Apr 5, 2015
@svaarala
Copy link
Owner

svaarala commented Apr 5, 2015

The 1.3.0 DUK_USE_xxx issue is tracked as #165.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants