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

Deeply nested capture groups cause stack overflow #68

k-takata opened this Issue Oct 19, 2016 · 1 comment


None yet
1 participant

k-takata commented Oct 19, 2016

How to reproduce:

from testpy import *
# import onigmo
# set_encoding("UTF-8")
# set_output_encoding()
x2("(" * 32767 + "a" + ")" * 32767, "a", 0, 1)

Related: #18 #24

This also occurs on Oniguruma 6.1.1.
Cc: @kkos

@k-takata k-takata added the bug label Oct 19, 2016

k-takata added a commit that referenced this issue Nov 28, 2016

Set a limit of parser recursion (Fix #68)
Our parser uses recursion, so it causes stack overflow when parsing
deeply nested capture groups. E.g.:

  x2("(" * 32767 + "a" + ")" * 32767, "a", 0, 1)

Set a limit for this.
The default value is defined in regint.h:

Also add two APIs to support this:
* onig_get_parse_depth_limit
* onig_set_parse_depth_limit

This comment has been minimized.

Show comment
Hide comment

k-takata Nov 28, 2016


Fixed in devel-6.0 branch with the commit e7a614b.


k-takata commented Nov 28, 2016

Fixed in devel-6.0 branch with the commit e7a614b.

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