<div dir="ltr"><a class="GWVZpf gW" id="IloFPc-2" href="mailto:clangd-dev@lists.llvm.org" tabindex="-1">+clangd-dev@lists.llvm.org</a> <a class="GWVZpf gW" id="IloFPc-3" href="mailto:ibiryukov@google.com" tabindex="-1">+Ilya Biryukov</a> <br></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Aug 17, 2018 at 2:41 PM <a href="mailto:Dmitry.Kozhevnikov@jetbrains.com">Dmitry.Kozhevnikov@jetbrains.com</a> via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello!<br>
<br>
clangd uses std::thread for spawning worker threads to parse files (see AsyncTaskRunner::runAsync in tools/clang/tools/extra/clangd/Threading.cpp). Unfortunately, std::thread lacks the ability to customize the stack size, and the default one might be insufficient for parsing complex source files. For example, on macOS, the default stack size for non-main threads is 512K, so the following code causes a stack overflow (on my machine) with clangd, while being way below the default constexpr evaluation depth threshold:<br>
<br>
        constexpr int foo(int x) {<br>
            return x == 1 ? 1 : foo(x - 1) + 1;<br>
        }<br>
        static_assert(foo(50) > 0, "");<br>
<br>
This also can be observed on some real-world projects.<br>
<br>
Do I understand correctly that the only way to fix it would be to abandon std::thread and reimplement the platform-specific thread spawning (using pthreads/WinAPI), or is there another solution available in LLVM/clang codebase?<br>
<br>
Best regards,<br>
Dmitry Kozhevnikov._______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>