Tuesday 2 April 2013

Fixing the "stack overflow in regexp matcher" error in Emacs.

I'm using a relatively large ctags file (~20 Mb) built for a C project I'm working on and I ran into the problem recently that the complete-symbol command (Ctrl-Alt-i) that auto-completes function and variable names in C files fails with the "stack overflow in regexp matcher" error.
Long story short, you need to increase the re_max_failures variable located in regex.c to fix this. Is this the right way? I don't know, but it works for me and the comments were not very clear to elaborate. There is also some "smart" logic related to re_max_failures in emacs.c that apparently tries to tweak it to the best value possible, but it turns out to be not smart enough for my use case.
This post was brought to you by GDB Reverse Debugging: Occasionally useful results for those who've got some lifetime to spare!