Mono, Regex and stack size

眉间皱痕 提交于 2019-12-24 14:03:01

问题


I'm porting a piece of C# software that uses System.Text.RegularExpressions.Regex for parsing out C/C++ includes out of source files. They are fully loaded into memory as a string and then just treated with the regex.

It works perfectly on Windows, but Mono running on Linux fails when trying to parse larger files with a stack overflow exception thrown from deep inside System.Text.RegularExpressions.Interpreter.

The code is perfectly correct - it works on Windows.

Is there a way to increase the stack size? Or do I really need to break up larger files into smaller chunks?

EDIT: The regex in question looks like this:

    /** Regex that matches #include statements. */
    static Regex CPPHeaderRegex = new Regex(    "(([ \t]*#[ \t]*include[ \t]*[<\"](?<HeaderFile>[^\">]*)[\">][^\n]*\n)|([^\n]*\n))*", 
                                                RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.ExplicitCapture );

The sources that cause problems are 300kB (~8k SLOC) and larger.

Mind you that this is not my code, I inherited it.

来源:https://stackoverflow.com/questions/14263148/mono-regex-and-stack-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!