Skip to content

Assertion failure building the compiler with full bootstrapping #70328

@hborla

Description

@hborla

Description

Building the compiler with full bootstrapping trips an assertion in the ASTVerifier:

1.	Swift version 5.11-dev (LLVM a2fd6a345facc7e, Swift d36173aa3c2da7d)
2.	Compiling with the current language version
3.	While walking into body of '__operatorSubscriptConst(_:)' (in module '__ObjC')
4.	While verifying VarDecl 'index' (in module '__ObjC')
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x00000001058a98e0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x00000001058a7f48 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x00000001058a9f38 SignalHandler(int) + 304
3  libsystem_platform.dylib 0x000000018382a584 _sigtramp + 56
4  libsystem_pthread.dylib  0x00000001837f9c28 pthread_kill + 288
5  libsystem_c.dylib        0x0000000183705a20 abort + 180
6  libsystem_c.dylib        0x0000000183704d10 err + 0
7  swift-frontend           0x0000000105f5c290 swift::GenericEnvironment::mapTypeIntoContext(swift::GenericEnvironment*, swift::Type) (.cold.4) + 0
8  swift-frontend           0x0000000101975a00 swift::GenericEnvironment::mapTypeIntoContext(swift::Type) const + 0
9  swift-frontend           0x00000001017b12b8 (anonymous namespace)::Verifier::verifyChecked(swift::VarDecl*) + 176
10 swift-frontend           0x00000001017a1654 (anonymous namespace)::Verifier::walkToDeclPost(swift::Decl*) + 3256
11 swift-frontend           0x00000001017b2fa8 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 316
12 swift-frontend           0x00000001017b6654 (anonymous namespace)::Traversal::visitAbstractFunctionDecl(swift::AbstractFunctionDecl*) + 376
13 swift-frontend           0x00000001017b5560 (anonymous namespace)::Traversal::visit(swift::Decl*) + 140
14 swift-frontend           0x00000001017b2f90 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 292
15 swift-frontend           0x00000001017b2e60 swift::Decl::walk(swift::ASTWalker&) + 32
16 swift-frontend           0x000000010179e8e0 swift::verify(swift::Decl*) + 208
17 swift-frontend           0x00000001014e065c swift::ClangImporter::verifyAllModules() + 456
18 swift-frontend           0x00000001016ec910 swift::ASTContext::verifyAllLoadedModules() const + 84

Reproduction

I ran

utils/build-script --skip-build-benchmarks --skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs arm64 --release-debuginfo --swift-disable-dead-stripping

Stack dump

1.	Swift version 5.11-dev (LLVM a2fd6a345facc7e, Swift d36173aa3c2da7d)
2.	Compiling with the current language version
3.	While walking into body of '__operatorSubscriptConst(_:)' (in module '__ObjC')
4.	While verifying VarDecl 'index' (in module '__ObjC')
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x00000001058a98e0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x00000001058a7f48 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x00000001058a9f38 SignalHandler(int) + 304
3  libsystem_platform.dylib 0x000000018382a584 _sigtramp + 56
4  libsystem_pthread.dylib  0x00000001837f9c28 pthread_kill + 288
5  libsystem_c.dylib        0x0000000183705a20 abort + 180
6  libsystem_c.dylib        0x0000000183704d10 err + 0
7  swift-frontend           0x0000000105f5c290 swift::GenericEnvironment::mapTypeIntoContext(swift::GenericEnvironment*, swift::Type) (.cold.4) + 0
8  swift-frontend           0x0000000101975a00 swift::GenericEnvironment::mapTypeIntoContext(swift::Type) const + 0
9  swift-frontend           0x00000001017b12b8 (anonymous namespace)::Verifier::verifyChecked(swift::VarDecl*) + 176
10 swift-frontend           0x00000001017a1654 (anonymous namespace)::Verifier::walkToDeclPost(swift::Decl*) + 3256
11 swift-frontend           0x00000001017b2fa8 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 316
12 swift-frontend           0x00000001017b6654 (anonymous namespace)::Traversal::visitAbstractFunctionDecl(swift::AbstractFunctionDecl*) + 376
13 swift-frontend           0x00000001017b5560 (anonymous namespace)::Traversal::visit(swift::Decl*) + 140
14 swift-frontend           0x00000001017b2f90 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 292
15 swift-frontend           0x00000001017b2e60 swift::Decl::walk(swift::ASTWalker&) + 32
16 swift-frontend           0x000000010179e8e0 swift::verify(swift::Decl*) + 208
17 swift-frontend           0x00000001014e065c swift::ClangImporter::verifyAllModules() + 456
18 swift-frontend           0x00000001016ec910 swift::ASTContext::verifyAllLoadedModules() const + 84

Expected behavior

I expected the build to succeed.

Environment

main at d36173a

Additional information

I believe this is a latent bug surfaced by an innocuous change in #67594 to call VarDecl::getTypeInContext() in the ASTVerifier. I confirmed that commenting out that call avoids the assertion.

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.c++ interopFeature: Interoperability with C++clang importerArea → compiler: The clang importercompilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwaregenericsFeature: generic declarations and typesswift 6.0verifier

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions