Skip to content

Driver crash when building Glibc overlay with explicit module builds #84740

@etcwilde

Description

@etcwilde

Description

There is a crash in the clang that is part of the internal dependency scanner when building the Glibc overlay with explicit module builds enabled. There seems to be some relationship between the VFS overlay, the modulemap, the SwiftGlibc header, and explicit module builds leading toward this outcome.

Reproduction

In your Swift sources, add $<$<COMPILE_LANGUAGE:Swift>:-explicit-module-builds> to the swiftGlibc library defined in Runtimes/Overlay/Linux/glibc/CMakeLists.txt to enable explicit module builds. This can be added to the target_compile_options at the bottom of the file. The sources should be built off of main.

host$  docker pull swiftlang/swift:nightly-debian12
host$  docker run --rm -it -v <path to swift Sources>:/sources bash
container#  <install necessary dependencies>
container#  cd /sources/swift/Runtimes
container#  cmake -G 'Ninja' -DCMAKE_INSTALL_PREFIX=/usr -B build-core -S Core
container#  cmake --build build-core
container#  DESTDIR=$PWD/SwiftSDK cmake --install build-core
container#  cmake -G 'Ninja' -DCMAKE_INSTALL_PREFIX=/usr -B build-overlay -S Overlay -DSwiftCore_DIR=$PWD/SwiftSDK/usr/lib/<path>/cmake/SwiftCore
container#  cmake --build build-overlay

The overlay build will crash.

Stack dump

swiftc: /home/build-user/llvm-project/clang/lib/Lex/Lexer.cpp:1216: SourceLocation clang::Lexer::getSourceLocation(const char *, unsigned int) const: Assertion `Loc >= BufferStart && Loc <= BufferEnd && "Location out of range for this buffer!"' failed.
swift-runtime: failed to suspend thread 2690 while processing a crash; backtraces will be missing information

*** Signal 6: Backtracing from 0xffff9d6d3c18... done ***

*** Program crashed: Aborted at 0x0000000000000a7c ***

Platform: arm64 Linux (Debian GNU/Linux 12 (bookworm))

Thread 0 "llvm-worker-2" crashed:

  0      0x0000ffff9d6d3c18 <unknown> in libc.so.6
  1 [ra] 0x0000ffff9d68a8ac <unknown> in libc.so.6
  2 [ra] 0x0000ffff9d677480 <unknown> in libc.so.6
  3 [ra] 0x0000ffff9d6842d8 <unknown> in libc.so.6
  4 [ra] 0x0000ffff9d68433c <unknown> in libc.so.6
  5 [ra] 0x0000ffff8e79bcfc clang::Lexer::convertDependencyDirectiveToken(clang::dependency_directives_scan::Token const&, clang::Token&) + 239 in lib_InternalSwiftScan.so
  6 [ra] 0x0000ffff8e79be8c clang::Lexer::LexDependencyDirectiveToken(clang::Token&) + 303 in lib_InternalSwiftScan.so
  7 [ra] 0x0000ffff8e807b8c clang::Preprocessor::Lex(clang::Token&) + 55 in lib_InternalSwiftScan.so
  8 [ra] 0x0000ffff8e7cb0c0 clang::Preprocessor::HandleDirective(clang::Token&) + 2291 in lib_InternalSwiftScan.so
  9 [ra] 0x0000ffff8e79bfd8 clang::Lexer::LexDependencyDirectiveToken(clang::Token&) + 635 in lib_InternalSwiftScan.so
 10 [ra] 0x0000ffff8e807b8c clang::Preprocessor::Lex(clang::Token&) + 55 in lib_InternalSwiftScan.so
 11 [ra] 0x0000ffff8cd3e7e0 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) + 779 in lib_InternalSwiftScan.so
 12 [ra] 0x0000ffff8cd3e3e0 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) + 55 in lib_InternalSwiftScan.so
 13 [ra] 0x0000ffff8cd3a684 clang::ParseAST(clang::Sema&, bool, bool) + 499 in lib_InternalSwiftScan.so
 14 [ra] 0x0000ffff8cb4113c clang::FrontendAction::Execute() + 111 in lib_InternalSwiftScan.so
 15 [ra] 0x0000ffff8cab9094 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1115 in lib_InternalSwiftScan.so
 16 [ra] 0x0000ffff8cac4af8 void llvm::function_ref<void ()>::callback_fn<compileModuleImpl(clang::CompilerInstance&, clang::SourceLocation, llvm::StringRef, clang::FrontendInputFile, llvm::StringRef, llvm::StringRef, llvm::function_ref<void (clang::CompilerInstance&)>, llvm::function_ref<void (clang::CompilerInstance&)>)::$_10>(long) + 131 in lib_InternalSwiftScan.so
 17 [ra] 0x0000ffff8f88e434 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 179 in lib_InternalSwiftScan.so
 18 [ra] 0x0000ffff8f88e540 RunSafelyOnThread_Dispatch(void*) + 27 in lib_InternalSwiftScan.so
 19 [ra] 0x0000ffff8f88e630 void* llvm::thread::ThreadProxy<std::tuple<void (*)(void*), (anonymous namespace)::RunSafelyOnThreadInfo*> >(void*) + 31 in lib_InternalSwiftScan.so
 20 [ra] 0x0000ffff9d6d2030 <unknown> in libc.so.6
...


Registers:

 x0 0x0000000000000000  0
 x1 0x0000000000000a84  2692
 x2 0x0000000000000006  6
 x3 0x0000ffff855800a0  01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ················
 x4 0x0000ffff9f629b98  00 a2 3d ac e0 3c d4 ff 00 00 00 00 00 00 00 00  ·¢=¬à<Ôÿ········
 x5 0x0000000000000001  1
 x6 0x0000000000000020  32
 x7 0x8d223c45050e4d3b  10169757175691234619
 x8 0x0000000000000083  131
 x9 0x0000ffff640757a0  15 bc e4 9b f0 ff 00 00 3b 4d 0e 05 45 3c 22 8d  ·¼ä·ðÿ··;M··E<"·
x10 0x00000000ffffff80  4294967168
x11 0x00000000ffffffd0  4294967248
x12 0x0000ffff8557f210  70 f2 57 85 ff ff 00 00 d8 42 68 9d ff ff 00 00  pòW·ÿÿ··ØBh·ÿÿ··
x13 0x0000000000002140  8512
x14 0x0000000000000000  0
x15 0x0000000000000017  23
x16 0x0000000000000001  1
x17 0x0000ffff9d6e29c4  80 08 00 b4 fd 7b bc a9 fd 03 00 91 f5 5b 02 a9  ···´ý{¼©ý···õ[·©
x18 0x0000ffff8e8b8ae0  ff 03 04 d1 e8 5b 00 fd fd fb 0b a9 f9 67 00 f9  ÿ··Ñè[·ýýû·©ùg·ù
x19 0x0000000000000a84  2692
x20 0x0000ffff855800a0  01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ················
x21 0x0000000000000006  6
x22 0x0000ffff927c2fd9  2f 68 6f 6d 65 2f 62 75 69 6c 64 2d 75 73 65 72  /home/build-user
x23 0x00000000000004c0  1216
x24 0x0000000000000001  1
x25 0x0000000000000000  0
x26 0x0000000000000000  0
x27 0x0000ffff640b1f20  68 eb e9 90 ff ff 00 00 e0 1f 00 64 ff ff 00 00  hëé·ÿÿ··à··dÿÿ··
x28 0x0000ffff855807e0  50 ef 22 80 ff ff 00 00 00 00 00 00 00 00 00 00  Pï"·ÿÿ··········
 fp 0x0000ffff8557f110  50 f1 57 85 ff ff 00 00 ac a8 68 9d ff ff 00 00  PñW·ÿÿ··¬¨h·ÿÿ··
 lr 0x0000ffff9d6d3c04  e1 03 13 aa e2 03 15 aa 00 7c 40 93 68 10 80 d2  á··ªâ··ª·|@·h··Ò
 sp 0x0000ffff8557f100  c0 04 00 00 00 00 00 00 00 a2 3d ac e0 3c d4 ff  À········¢=¬à<Ôÿ
 pc 0x0000ffff9d6d3c18  1f 04 40 31 e0 97 80 5a df ff ff 17 e0 03 16 aa  ··@1à··Zßÿÿ·à··ª


Images (37 omitted):

0x0000ffff87ad0000–0x0000ffff908a1d30 34feb757ad4147e04f5fcd8199836b919c6d47a1 lib_InternalSwiftScan.so /opt/swift/6.2/usr/lib/swift/host/compiler/lib_InternalSwiftScan.so
0x0000ffff9d650000–0x0000ffff9d7da7fc 3ff3f95a1642952473d0d5739aaf308b0e24f694 libc.so.6                /usr/lib/aarch64-linux-gnu/libc.so.6

Backtrace took 0.06s

Aborted
ninja: build stopped: subcommand failed.

Expected behavior

No crash

Environment

Swift version 6.3-dev (LLVM 0d0246569621d5b, Swift 199240b)
Target: aarch64-unknown-linux-gnu
Build config: +assertions

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwaretriage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions