Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

clang-9 RC ICE when building clangd with -DLLVM_ENABLE_MODULES=On #41797

Open Quuxplusone opened 4 years ago

Quuxplusone commented 4 years ago
Bugzilla Link PR42827
Status NEW
Importance P release blocker
Reported by Brian Gesiak (modocache@gmail.com)
Reported on 2019-07-30 08:13:07 -0700
Last modified on 2019-08-27 05:40:51 -0700
Version 9.0
Hardware All All
CC ahatanak@gmail.com, dgregor@apple.com, hans@chromium.org, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk, thomas.preudhomme@celest.fr
Fixed by commit(s)
Attachments repro.sh (2585 bytes, application/x-sh)
Blocks
Blocked by
See also
Created attachment 22315
A script I used to reproduce the issue. It builds clang, then uses it to
compile clangd with LLVM_ENABLE_MODULES. I also used this script to bisect.

As I explained in my email to llvm-dev on July 29,
http://lists.llvm.org/pipermail/llvm-dev/2019-July/134214.html, I am running
into a Clang ICE when I use a clang-9 built from llvm-project's release/9.x
branch to compile clangd from the release/9.x branch source.

I wrote a script to reproduce the issue, and posted the output from running
that script, in
https://gist.github.com/modocache/ac366ca9673b93bb21e75d3e72162608. I'll also
attach those files to this bug.

I used the script above to bisect, and I found that the first commit that
demonstrates the issue is https://github.com/llvm/llvm-
project/commit/baae41ff76f662987f31447686ba819dcd748b3f.

In the email discussion, I was asked to verify whether the issue reproduces on
llvm-project master. It does for me, and I posted the repro script and its
output to https://gist.github.com/modocache/d9700166067f4a155820bc57d9bee1f3.

However, the issue doesn't appear to occur in buildbots such as
http://green.lab.llvm.org/green/job/clang-stage2-coverage-R/4124/console, which
use -DLLVM_ENABLE_MODULES=On. I can't explain why at the moment.

For now I'm registering this bug as a release blocker for 9.0.0 RC 1, please
let me know if that's appropriate.
Quuxplusone commented 4 years ago

Attached repro.sh (2585 bytes, application/x-sh): A script I used to reproduce the issue. It builds clang, then uses it to compile clangd with LLVM_ENABLE_MODULES. I also used this script to bisect.

Quuxplusone commented 4 years ago
(In reply to Brian Gesiak from comment #0)
>
> However, the issue doesn't appear to occur in buildbots such as
> http://green.lab.llvm.org/green/job/clang-stage2-coverage-R/4124/console,
> which use -DLLVM_ENABLE_MODULES=On. I can't explain why at the moment.

I'm confused by that sentence, the end of the log contains the following:

[2793/4585] /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/host-
compiler/bin/clang++  -DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/clang/tools/extra/clangd -
I/Users/buildslave/jenkins/workspace/clang-stage2-coverage-
R/llvm/tools/clang/tools/extra/clangd -
I/Users/buildslave/jenkins/workspace/clang-stage2-coverage-
R/llvm/tools/clang/include -Itools/clang/include -
I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2
-Iinclude -I/Users/buildslave/jenkins/workspace/clang-stage2-coverage-
R/llvm/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -
Werror=unguarded-availability-new -std=c++11 -fmodules -fmodules-cache-
path=/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/clang-
build/module.cache -fcxx-modules -Wall -Wextra -Wno-unused-parameter -Wwrite-
strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -
Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-
dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -
fprofile-instr-generate='/Users/buildslave/jenkins/workspace/clang-stage2-
coverage-R/clang-build/profiles/%6m.profraw' -fcoverage-mapping -fno-common -
Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
-fno-exceptions -fno-rtti -MD -MT
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/FindSymbols.cpp.o
-MF
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/FindSymbols.cpp.o.d
-o
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/FindSymbols.cpp.o
-c /Users/buildslave/jenkins/workspace/clang-stage2-coverage-
R/llvm/tools/clang/tools/extra/clangd/FindSymbols.cpp
FAILED:
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/FindSymbols.cpp.o
/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/host-
compiler/bin/clang++  -DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/clang/tools/extra/clangd -
I/Users/buildslave/jenkins/workspace/clang-stage2-coverage-
R/llvm/tools/clang/tools/extra/clangd -
I/Users/buildslave/jenkins/workspace/clang-stage2-coverage-
R/llvm/tools/clang/include -Itools/clang/include -
I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2
-Iinclude -I/Users/buildslave/jenkins/workspace/clang-stage2-coverage-
R/llvm/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -
Werror=unguarded-availability-new -std=c++11 -fmodules -fmodules-cache-
path=/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/clang-
build/module.cache -fcxx-modules -Wall -Wextra -Wno-unused-parameter -Wwrite-
strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -
Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-
dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -
fprofile-instr-generate='/Users/buildslave/jenkins/workspace/clang-stage2-
coverage-R/clang-build/profiles/%6m.profraw' -fcoverage-mapping -fno-common -
Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
-fno-exceptions -fno-rtti -MD -MT
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/FindSymbols.cpp.o
-MF
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/FindSymbols.cpp.o.d
-o
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/FindSymbols.cpp.o
-c /Users/buildslave/jenkins/workspace/clang-stage2-coverage-
R/llvm/tools/clang/tools/extra/clangd/FindSymbols.cpp
Assertion failed: (CachedFieldIndex && "failed to find field in parent"),
function getFieldIndex, file /Users/buildslave/jenkins/workspace/clang-stage1-
configure-RA/llvm/tools/clang/lib/AST/Decl.cpp, line 3965.
Stack dump:
0.  Program arguments: /Users/buildslave/jenkins/workspace/clang-stage2-coverage-
R/host-compiler/bin/clang-9 -cc1 -triple x86_64-apple-macosx10.14.0 -
Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -disable-
free -main-file-name FindSymbols.cpp -mrelocation-model pic -pic-level 2 -
mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-sdk-
version=10.14 -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -ggnu-
pubnames -target-linker-version 409.12 -fprofile-instrument-
path=/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/clang-
build/profiles/%6m.profraw -fprofile-instrument=clang -fcoverage-mapping -
coverage-notes-file /Users/buildslave/jenkins/workspace/clang-stage2-coverage-
R/clang-
build/tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/FindSymbols.cpp.gcno
-resource-dir /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/host-
compiler/lib/clang/9.0.0 -dependency-file
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/FindSymbols.cpp.o.d
-sys-header-deps -MT
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/FindSymbols.cpp.o
-isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
-D GTEST_HAS_RTTI=0 -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D
__STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I tools/clang/tools/extra/clangd -
I /Users/buildslave/jenkins/workspace/clang-stage2-coverage-
R/llvm/tools/clang/tools/extra/clangd -I
/Users/buildslave/jenkins/workspace/clang-stage2-coverage-
R/llvm/tools/clang/include -I tools/clang/include -I
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2
-I include -I /Users/buildslave/jenkins/workspace/clang-stage2-coverage-
R/llvm/include -D NDEBUG -stdlib=libc++ -internal-isystem
/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/host-
compiler/bin/../include/c++/v1 -internal-isystem
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/v1
-internal-isystem
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/local/include
-internal-isystem /Users/buildslave/jenkins/workspace/clang-stage2-coverage-
R/host-compiler/lib/clang/9.0.0/include -internal-externc-isystem
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include
-O3 -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-
unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wno-
long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -
Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -Woverloaded-
virtual -Wno-nested-anon-types -pedantic -std=c++11 -fdeprecated-macro -fdebug-
compilation-dir /Users/buildslave/jenkins/workspace/clang-stage2-coverage-
R/clang-build -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -
stack-protector 1 -fblocks -fencode-extended-block-signature -fno-rtti -
fregister-global-dtors-with-atexit -fmodules -fimplicit-module-maps -fmodules-
cache-path=/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/clang-
build/module.cache -fmodules-validate-system-headers -fobjc-runtime=macosx-
10.14.0 -fmax-type-align=16 -fno-common -fdiagnostics-show-option -fcolor-
diagnostics -vectorize-loops -vectorize-slp -o
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/FindSymbols.cpp.o
-x c++ /Users/buildslave/jenkins/workspace/clang-stage2-coverage-
R/llvm/tools/clang/tools/extra/clangd/FindSymbols.cpp
1.  <eof> parser at end of file
2.  Per-file LLVM IR generation
3.  /Users/buildslave/jenkins/workspace/clang-stage2-coverage-
R/llvm/include/llvm/Support/Error.h:625:17: Generating code for declaration
'llvm::Expected<std::__1::basic_string<char> >::getStorage'
0  clang-9                  0x000000010adb0fe8
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  clang-9                  0x000000010adb0195 llvm::sys::RunSignalHandlers() +
85
2  clang-9                  0x000000010adb15f8 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff7de97b3d _sigtramp + 29
4  libsystem_platform.dylib 0x00007fd9204d6720 _sigtramp + 2724457472
5  libsystem_c.dylib        0x00007fff7dd561c9 abort + 127
6  libsystem_c.dylib        0x00007fff7dd1e868 basename_r + 0
7  clang-9                  0x000000010cb0bdf6
clang::FieldDecl::getFieldIndex() const + 694
8  clang-9                  0x000000010b0a3722
clang::CodeGen::CodeGenFunction::EmitLValueForField(clang::CodeGen::LValue,
clang::FieldDecl const*) + 1442
9  clang-9                  0x000000010b0ae2af
clang::CodeGen::CodeGenFunction::EmitMemberExpr(clang::MemberExpr const*) + 1247
10 clang-9                  0x000000010b0a009a
clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) + 1018
11 clang-9                  0x000000010b0a83ed
clang::CodeGen::CodeGenFunction::EmitCheckedLValue(clang::Expr const*,
clang::CodeGen::CodeGenFunction::TypeCheckKind) + 173
12 clang-9                  0x000000010b0adf06
clang::CodeGen::CodeGenFunction::EmitMemberExpr(clang::MemberExpr const*) + 310
13 clang-9                  0x000000010b0a009a
clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) + 1018
14 clang-9                  0x000000010b0af290
clang::CodeGen::CodeGenFunction::EmitCastLValue(clang::CastExpr const*) + 800
15 clang-9                  0x000000010b09fd1f
clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) + 127
16 clang-9                  0x000000010b0a83ed
clang::CodeGen::CodeGenFunction::EmitCheckedLValue(clang::Expr const*,
clang::CodeGen::CodeGenFunction::TypeCheckKind) + 173
17 clang-9                  0x000000010b0adf06
clang::CodeGen::CodeGenFunction::EmitMemberExpr(clang::MemberExpr const*) + 310
18 clang-9                  0x000000010b0a009a
clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) + 1018
19 clang-9                  0x000000010b0a7cf7
clang::CodeGen::CodeGenFunction::EmitArrayToPointerDecay(clang::Expr const*,
clang::CodeGen::LValueBaseInfo*, clang::CodeGen::TBAAAccessInfo*) + 119
20 clang-9                  0x000000010b0f7cee (anonymous
namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) + 3758
21 clang-9                  0x000000010b0f6ee4 (anonymous
namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) + 164
22 clang-9                  0x000000010b0e4d78
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) + 104
23 clang-9                  0x000000010b1d971b
clang::CodeGen::CodeGenFunction::EmitReturnStmt(clang::ReturnStmt const&) + 1435
24 clang-9                  0x000000010b1d693e
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*,
llvm::ArrayRef<clang::Attr const*>) + 2510
25 clang-9                  0x000000010b1decaf
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot) + 95
26 clang-9                  0x000000010b21e997
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 791
27 clang-9                  0x000000010b239737
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) + 503
28 clang-9                  0x000000010b233656
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) + 486
29 clang-9                  0x000000010b229641
clang::CodeGen::CodeGenModule::EmitDeferred() + 289
30 clang-9                  0x000000010b229669
clang::CodeGen::CodeGenModule::EmitDeferred() + 329
31 clang-9                  0x000000010b229669
clang::CodeGen::CodeGenModule::EmitDeferred() + 329
32 clang-9                  0x000000010b22891a
clang::CodeGen::CodeGenModule::Release() + 42
33 clang-9                  0x000000010b2b05f4 (anonymous
namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) + 100
34 clang-9                  0x000000010b2153e6
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 134
35 clang-9                  0x000000010c0f03d3 clang::ParseAST(clang::Sema&,
bool, bool) + 611
36 clang-9                  0x000000010b4949c4 clang::FrontendAction::Execute()
+ 84
37 clang-9                  0x000000010b4465e8
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1544
38 clang-9                  0x000000010b50ce80
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1808
39 clang-9                  0x00000001091dacc4 cc1_main(llvm::ArrayRef<char
const*>, char const*, void*) + 2356
40 clang-9                  0x00000001091d8343 main + 10851
41 libdyld.dylib            0x00007fff7dcae085 start + 1
Quuxplusone commented 4 years ago
By the way, I've managed to gather the following clues:

1) the minimal FileCheck.h that reproduces this error is:

#ifndef LLVM_SUPPORT_FILECHECK_H
#define LLVM_SUPPORT_FILECHECK_H

#include "llvm/Support/Error.h"
#include <string>

llvm::Expected<std::string> getFileCheckResult();
#endif

2) Changing Expected to Optional or std::string to anything else (e.g.
StringRef or int) allows the file to compile

3) Moving FileCheck.h to llvm/include/llvm/Object also allows compilation to
proceeed

4) Removing -fimplicit-module-maps from the cc1 command-line allows compilation
to proceed as well
Quuxplusone commented 4 years ago

Making TStorage and ErrorStorage direct members of class Expected also makes the build error go away. I suspect this is a bug in clang that got exposed by r363900.

Quuxplusone commented 4 years ago

While it would be good to get to the bottom of this, I don't think it should block the 9 release.