Open aslushnikov opened 3 years ago
It would be helpful if you could narrow down which source file triggers the stack overflow.
You can do this by running clangd-indexer
with the additional argument --execute-concurrency=1
. It will then perform the indexing on a single thread, and you can look for the last line of output of the form [X/Y] Processing file <filename>
before the stack overflow.
@HighCommander4 Thank you for the instructions! I reduced compilation database to the following:
[{
"directory":"/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/obj-build-playwright/parser/html",
"command":"/usr/bin/clang++ -isysroot /Users/aslushnikov/SDK-archive/MacOSX10.12.sdk/ -std=gnu++17 -o /dev/null -c -fvisibility=hidden -fvisibility-inlines-hidden -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -DNDEBUG=1 -DTRIMMED=1 -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -DSTATIC_EXPORTABLE_JS_API -I/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html -I/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/obj-build-playwright/parser/html -I/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/dom/base -I/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/obj-build-playwright/dist/include -I/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/obj-build-playwright/dist/include/nspr -I/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/obj-build-playwright/dist/include/nss -fPIC -DMOZILLA_CLIENT -include /Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/obj-build-playwright/mozilla-config.h -Qunused-arguments -Qunused-arguments -Wall -Wbitfield-enum-conversion -Wempty-body -Wignored-qualifiers -Woverloaded-virtual -Wpointer-arith -Wshadow-field-in-constructor-modified -Wsign-compare -Wtype-limits -Wunreachable-code -Wunreachable-code-return -Wwrite-strings -Wno-invalid-offsetof -Wclass-varargs -Wempty-init-stmt -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wloop-analysis -Wno-range-loop-analysis -Wc++2a-compat -Wcomma -Wimplicit-fallthrough -Wunused-function -Wunused-variable -Wstring-conversion -Wtautological-overlap-compare -Wtautological-unsigned-enum-zero-compare -Wtautological-unsigned-zero-compare -Wno-error=tautological-type-limit-compare -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=backend-plugin -Wno-error=return-std-move -Wno-error=atomic-alignment -Wformat -Wformat-security -Wno-gnu-zero-variadic-macro-arguments -Wno-unknown-warning-option -fno-sized-deallocation -fno-aligned-new -fno-exceptions -fno-strict-aliasing -stdlib=libc++ -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -pipe -g -O3 -fomit-frame-pointer -funwind-tables -Wno-error=shadow -ferror-limit=0 Unified_cpp_parser_html0.cpp",
"file":"/Users/aslushnikov/prog/playwright/browser_patches/firefox/checkout/parser/html/nsHtml5HtmlAttributes.cpp"
}]
Note that mozilla build system groups C++ sources. The Unified_cpp_parser_html0.cpp
is a concatenation of 16 other sources:
Unified_cpp_parser_html0.cpp
Do you get the stack overflow if you cd
into that directory
and manually run that command
(using the clang
from the same LLVM distrbution that your clangd
is from)?
Do you get the stack overflow if you cd into that directory and manually run that command (using the clang from the same LLVM distrbution that your clangd is from)?
@HighCommander4 No, there's no stack overflow.
Just in case, I forgot to mention that I have to add additional -I
flags so that include paths work the same way as in my standard clang++ at /usr/bin/clang++
. I pass these as multiple --extra-arg=
CLI option to clangd-indexer.
I do get some error: use of undeclared identifier '__builtin_ia32_storehps'
errors though, but I don't think that's of much importance for indexing.
Thanks. One more thing that would be helpful: could you run the compile command, with the extra arguments added, and also with -c
replaced with -E
("only preprocess, do not compile"), and -o /dev/null
replaced with -o preprocessed.cpp
, and then upload preprocessed.cpp
as an attachment?
@HighCommander4 sure thing, here it is: preprocessed.cpp.zip
Thanks. I am not able to reproduce the stack overflow on the preprocessed source file.
However, I don't have a Mac and was testing on Linux, so I may not be exercising some relevant codepaths.
Perhaps someone with a Mac can test and see if they can reproduce the stack overflow on the preprocessed source file.
@HighCommander4 I just tried running ./build/bin/clangd-indexer preprocessed.cpp > out.dex
and it didn't crash for me as well. So maybe I did something wrong when generating the preprocessed.cpp
- let me carefully check everything.
Meanwhile, if you have any more suggestions - I'd be happy to try things.
I noticed the compile command contains a -include /<...>/mozilla-config.h
argument as well. Could you upload that file as well?
@HighCommander4 The following results in a stackoverflow error for me on Mac 10.15:
compile_commands.json
[{
"directory":"/Users/aslushnikov/prog/llvm",
"command":"/usr/bin/clang++ -std=gnu++17 -o /dev/null -c preprocessed.cpp",
"file":"/Users/aslushnikov/prog/llvm/preprocessed.cpp"
}]
$ ./build/bin/clangd-indexer ./compile_commands.json --executor=all-TUs --execute-concurrency=1
Interestingly, simply running ./build/bin/clangd-indexer --extra-arg="-std=gnu++17" preprocessed.cpp > out.dex
works fine.
I noticed the compile command contains a -include /<...>/mozilla-config.h argument as well. Could you upload that file as well?
@HighCommander4 Here it is: mozilla-config.h.zip. Though I'm able to reproduce the same StackOverflow without this include.
@HighCommander4 Unfortunately, I wasn't able to reproduce this crash on my Ubuntu 20.04. However, I was trying to reproduce the crash by cross-compiling from Linux to MacOS, so I'm not sure how relevant this is.
Hi folks,
I'm running
clangd-indexer
from llvm 12.0.0-rc2 against Firefox source code that we use at Playwright. Unfortunately, it is crashing for me, so I built a debug version with ASAN enabledRunning the ASAN build yields a "stackoverflow" signal from ASAN (full-asan-report.txt)
Local reproduction is somewhat involved since it requires building firefox on mac, so I'd be happy to follow-up if you have any questions. If you still want to reproduce this locally, here are the instructions to do that:
clang++ -E -x c++ - -v < /dev/null
and pass them all as--extra-arg="-I..."
args to theclangd-indexer
System information Output of
clangd --version
:Editor/LSP plugin: N/A Operating system: Mac 10.15.4