• Noam Postavsky's avatar
    Use expanded stack during regex matches · 13c6f1d1
    Noam Postavsky authored
    
    
    While the stack is increased in main(), to allow the regex stack
    allocation to use alloca we also need to modify regex.c to actually take
    advantage of the increased stack, and not limit stack allocations to
    SAFE_ALLOCA bytes.
    
    * src/regex.c (MATCH_MAY_ALLOCATE): Remove obsolete comment about
    allocations in signal handlers which no longer happens and correct
    description about when and why MATCH_MAY_ALLOCATE should be defined.
    (emacs_re_safe_alloca): New variable.
    (REGEX_USE_SAFE_ALLOCA): Use it as the limit of stack allocation instead
    of MAX_ALLOCA.
    (emacs_re_max_failures): Rename from `re_max_failures' to avoid
    confusion with glibc's `re_max_failures'.
    * src/emacs.c (main): Increase the amount of fixed 'extra' bytes we add
    to the stack.  Instead of changing emacs_re_max_failures based on the
    new stack size, just change emacs_re_safe_alloca; emacs_re_max_failures
    remains constant regardless, since if we run out stack space SAFE_ALLOCA
    will fall back to heap allocation.
    Co-authored-by: default avatarEli Zaretskii <eliz@gnu.org>
    13c6f1d1
regex.h 23.2 KB