New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PCH module cache path crash #875
Comments
This log is kind of interesting:
When I've seen something similar to this in the past the issue was something like artifacts pointing to 1 module cache path were being referenced from a build pointing to another, and that caused the failure. The CI machines appear to re-use artifacts across builds, but I would expect it would require a pretty big change, maybe an Xcode version bump?, without cleaning to cause something like this. 🤔 |
Correct. I cleaned both CI machines earlier today for a different change, so I'll report back if I see this again. |
Did ya'll ever figure out the issue here, I'm able to reproduce with a sort of simple setup. A Error: ERROR: Tools/ModuleWeights/BUILD.bazel:9:14: Compiling Swift module //Tools/ModuleWeights:ModuleWeights.library failed: (Exit 1): worker failed: error executing command (from target //Tools/ModuleWeights:ModuleWeights.library)
(cd /private/var/tmp/_bazel_lpadron/9ae9416857eb79bb978de35a53d54970/execroot/cash-ios && \
exec env - \
APPLE_SDK_PLATFORM=MacOSX \
APPLE_SDK_VERSION_OVERRIDE=13.1 \
SWIFT_AVOID_WARNING_USING_OLD_DRIVER=1 \
XCODE_VERSION_OVERRIDE=14.2.0.14C18 \
bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/build_bazel_rules_swift/tools/worker/worker swiftc @bazel-out/darwin_arm64-dbg/bin/Tools/ModuleWeights/ModuleWeights.swiftmodule-0.params)
# Configuration: 7f4d8ee0b96abffee3a3a00333e5bb49718726c089d95165cd6973076f1084c4
# Execution platform: @local_config_platform//:host
error: compile command failed due to signal 11 (use -v to see invocation)
<unknown>:0: error: PCH was compiled with module cache path '/private/var/tmp/_bazel_lpadron/9ae9416857eb79bb978de35a53d54970/execroot/cash-ios/bazel-out/darwin_arm64-dbg/bin/_swift_module_cache/NRNUEGJDXPX2', but the path is currently '/private/var/tmp/_bazel_lpadron/9ae9416857eb79bb978de35a53d54970/execroot/cash-ios/bazel-out/darwin_arm64-dbg/bin/_swift_module_cache/2CGXMPK9674O2'
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0. Program arguments: /Applications/Xcode-14.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file Tools/ModuleWeights/Sources/ModuleWeights/ModuleGraph+LinesOfCodeSummary.swift -primary-file Tools/ModuleWeights/Sources/ModuleWeights/ModuleLinesOfCodeSummary.swift -primary-file Tools/ModuleWeights/Sources/ModuleWeights/Tool.swift -target arm64-apple-macos12.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode-14.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -I bazel-out/darwin_arm64-dbg/bin/external/swiftpkg_cwlcatchexception -I bazel-out/darwin_arm64-dbg/bin/external/swiftpkg_glob -I bazel-out/darwin_arm64-dbg/bin/external/swiftpkg_yams -I bazel-out/darwin_arm64-dbg/bin/Tools/Frameworks/ModuleGraph -I bazel-out/darwin_arm64-dbg/bin/external/swiftpkg_swift_argument_parser -enable-testing -g -module-cache-path bazel-out/darwin_arm64-dbg/bin/_swift_module_cache -static -Onone -D DEBUG -D SWIFT_PACKAGE -D SWIFT_PACKAGE -D YAML_DECLARE_STATIC -debug-prefix-map /Applications/Xcode-14.2.0.app/Contents/Developer=DEVELOPER_DIR -file-prefix-map /Applications/Xcode-14.2.0.app/Contents/Developer=DEVELOPER_DIR -debug-prefix-map /private/var/tmp/_bazel_lpadron/9ae9416857eb79bb978de35a53d54970/execroot/cash-ios=. -file-prefix-map /private/var/tmp/_bazel_lpadron/9ae9416857eb79bb978de35a53d54970/execroot/cash-ios=. -new-driver-path /Applications/Xcode-14.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -no-clang-module-breadcrumbs -no-serialize-debugging-options -color-diagnostics -enable-bare-slash-regex -empty-abi-descriptor -resource-dir /Applications/Xcode-14.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -Xcc -Iexternal/swiftpkg_cwlcatchexception/Sources/CwlCatchExceptionSupport/include -Xcc -Ibazel-out/darwin_arm64-dbg/bin/external/swiftpkg_cwlcatchexception/Sources/CwlCatchExceptionSupport/include -Xcc -Ibazel-out/darwin_arm64-dbg/bin/external/swiftpkg_cwlcatchexception/CwlCatchExceptionSupport -Xcc -iquoteexternal/swiftpkg_cwlcatchexception -Xcc -iquotebazel-out/darwin_arm64-dbg/bin/external/swiftpkg_cwlcatchexception -Xcc -iquoteexternal/swiftpkg_yams -Xcc -iquotebazel-out/darwin_arm64-dbg/bin/external/swiftpkg_yams -Xcc -iquote. -Xcc -iquotebazel-out/darwin_arm64-dbg/bin -Xcc -isystemexternal/swiftpkg_yams/Sources/CYaml/include -Xcc -isystembazel-out/darwin_arm64-dbg/bin/external/swiftpkg_yams/Sources/CYaml/include -Xcc -DSWIFT_PACKAGE -Xcc -DSWIFT_PACKAGE=1 -Xcc -DYAML_DECLARE_STATIC -Xcc -fmodule-map-file=bazel-out/darwin_arm64-dbg/bin/external/swiftpkg_cwlcatchexception/Sources_CwlCatchExceptionSupport.swift.modulemap -Xcc -fmodule-map-file=bazel-out/darwin_arm64-dbg/bin/external/swiftpkg_cwlcatchexception/Sources_CwlCatchExceptionSupport_modulemap.swift.modulemap -Xcc -fmodule-map-file=bazel-out/darwin_arm64-dbg/bin/external/swiftpkg_yams/Sources_CYaml.swift.modulemap -Xcc -O0 -Xcc -DDEBUG=1 -Xcc -fstack-protector -Xcc -fstack-protector-all -module-name ModuleWeights -disable-clang-spi -target-sdk-version 13.1 -parse-as-library -o bazel-out/darwin_arm64-dbg/bin/Tools/ModuleWeights/ModuleWeights.library_objs/Sources/ModuleWeights/ModuleGraph+LinesOfCodeSummary.swift.o -o bazel-out/darwin_arm64-dbg/bin/Tools/ModuleWeights/ModuleWeights.library_objs/Sources/ModuleWeights/ModuleLinesOfCodeSummary.swift.o -o bazel-out/darwin_arm64-dbg/bin/Tools/ModuleWeights/ModuleWeights.library_objs/Sources/ModuleWeights/Tool.swift.o
1. Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
2. Compiling with the current language version
3. While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "Tools/ModuleWeights/Sources/ModuleWeights/Tool.swift")
4. While silgen emitArtificialTopLevel SIL function "@async_Main".
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 0x0000000106cfb5b0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 swift-frontend 0x0000000106cfa5b4 llvm::sys::RunSignalHandlers() + 112
2 swift-frontend 0x0000000106cfbc34 SignalHandler(int) + 344
3 libsystem_platform.dylib 0x0000000195b5aa24 _sigtramp + 56
4 swift-frontend 0x00000001024048b0 swift::SILFunctionBuilder::getOrCreateFunction(swift::SILLocation, swift::SILDeclRef, swift::ForDefinition_t, llvm::function_ref<swift::SILFunction* (swift::SILLocation, swift::SILDeclRef)>, swift::ProfileCounter) + 84
5 swift-frontend 0x00000001024048b0 swift::SILFunctionBuilder::getOrCreateFunction(swift::SILLocation, swift::SILDeclRef, swift::ForDefinition_t, llvm::function_ref<swift::SILFunction* (swift::SILLocation, swift::SILDeclRef)>, swift::ProfileCounter) + 84
6 swift-frontend 0x00000001028fbfa8 swift::Lowering::SILGenModule::getFunction(swift::SILDeclRef, swift::ForDefinition_t) + 384
7 swift-frontend 0x000000010298e3cc swift::Lowering::SILGenFunction::emitArtificialTopLevel(swift::Decl*) + 1844
8 swift-frontend 0x00000001028fd854 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 4216
9 swift-frontend 0x000000010290419c swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 4052
10 swift-frontend 0x00000001029d0f10 swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> > (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::ASTLoweringRequest const&, swift::Evaluator&) + 216
11 swift-frontend 0x00000001029076e4 llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 628
12 swift-frontend 0x0000000102348758 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 5860
13 swift-frontend 0x00000001022e9294 swift::mainEntry(int, char const**) + 3940
14 dyld 0x00000001957d3f28 start + 2236 The package is pretty simple: swift_binary(
name = "ModuleWeights",
visibility = ["//visibility:public"],
deps = [":ModuleWeights.library"],
)
swift_library(
name = "ModuleWeights.library",
srcs = glob(["Sources/ModuleWeights/**/*.swift"]),
module_name = "ModuleWeights",
tags = ["manual"],
deps = [
"//Tools/Frameworks/ModuleGraph",
"//Tools/Frameworks/ModuleGraph:ModuleGraph_LinesOfCode",
"@swiftpkg_cwlcatchexception//:Sources_CwlCatchException",
"@swiftpkg_swift_argument_parser//:Sources_ArgumentParser",
],
) And the code which crashes is simply: @main
struct ModuleWeights: AsyncParsableCommand {
...
} |
if it is the exact same case I never got around to finishing the fix apple/swift#60636 |
Thanks @keith! Did ya'll end up working around this somehow? |
If you use async behavior anywhere else in the code I think you sidestep it |
Do you know where exactly the other async code goes? This tool does import other async code and uses I wonder if we can make this match whatever SPM is doing, this seems to work correctly there. I haven't been able to reproduce in a |
Was able to track this down further, to specifically only happening when depending on Yams package. I was doing this via Will see if i can repro in Edit: Never mind, that seems to have fixed it for the build locally, CI still failed for us. I also cleared all my caches and re-built locally and see the same failure now |
It's a race condition so I'm not surprised it's in and out. I can't recall if I could repro with swiftpm or not, you'd have to pass the flag mentioned in my fix PR to do so, which swiftpm does not by default. |
Heres a /Applications/Xcode-14.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /Users/lpadron/Development/cash-ios/Tools/ModuleWeights/Sources/ModuleWeights/ModuleGraph+LinesOfCodeSummary.swift /Users/lpadron/Development/cash-ios/Tools/ModuleWeights/Sources/ModuleWeights/ModuleLinesOfCodeSummary.swift /Users/lpadron/Development/cash-ios/Tools/ModuleWeights/Sources/ModuleWeights/Tool.swift -emit-dependencies-path /Users/lpadron/Development/cash-ios/Tools/ModuleWeights/.build/arm64-apple-macosx/debug/ModuleWeights.build/ModuleGraph+LinesOfCodeSummary.d -emit-reference-dependencies-path /Users/lpadron/Development/cash-ios/Tools/ModuleWeights/.build/arm64-apple-macosx/debug/ModuleWeights.build/ModuleGraph+LinesOfCodeSummary.swiftdeps -target arm64-apple-macosx12.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode-14.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -I /Users/lpadron/Development/cash-ios/Tools/ModuleWeights/.build/arm64-apple-macosx/debug -I /Applications/Xcode-14.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Applications/Xcode-14.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -color-diagnostics -enable-testing -g -module-cache-path /Users/lpadron/Development/cash-ios/Tools/ModuleWeights/.build/arm64-apple-macosx/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -new-driver-path /Applications/Xcode-14.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -entry-point-function-name ModuleWeights_main -empty-abi-descriptor -resource-dir /Applications/Xcode-14.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -Xcc -fmodule-map-file=/Users/lpadron/Development/cash-ios/Tools/ModuleWeights/.build/checkouts/Yams/Sources/CYaml/include/module.modulemap -Xcc -I -Xcc /Users/lpadron/Development/cash-ios/Tools/ModuleWeights/.build/checkouts/Yams/Sources/CYaml/include -Xcc -fmodule-map-file=/Users/lpadron/Development/cash-ios/Tools/ModuleWeights/.build/arm64-apple-macosx/debug/CwlCatchExceptionSupport.build/module.modulemap -Xcc -I -Xcc /Users/lpadron/Development/cash-ios/Tools/ModuleWeights/.build/checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/include -module-name ModuleWeights -disable-clang-spi -target-sdk-version 13.1 -o /Users/lpadron/Development/cash-ios/Tools/ModuleWeights/.build/arm64-apple-macosx/debug/ModuleWeights.build/ModuleGraph+LinesOfCodeSummary.swift.o -index-store-path /Users/lpadron/Development/cash-ios/Tools/ModuleWeights/.build/arm64-apple-macosx/debug/index/store -index-system-modules And the same Bazel command: /Applications/Xcode-14.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file Tools/ModuleWeights/Sources/ModuleWeights/ModuleGraph+LinesOfCodeSummary.swift -primary-file Tools/ModuleWeights/Sources/ModuleWeights/ModuleLinesOfCodeSummary.swift -primary-file Tools/ModuleWeights/Sources/ModuleWeights/Tool.swift -target arm64-apple-macos12.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode-14.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -I bazel-out/darwin_arm64-dbg/bin/external/swiftpkg_cwlcatchexception -I bazel-out/darwin_arm64-dbg/bin/external/swiftpkg_glob -I bazel-out/darwin_arm64-dbg/bin/external/yams -I bazel-out/darwin_arm64-dbg/bin/Tools/Frameworks/ModuleGraph -I bazel-out/darwin_arm64-dbg/bin/external/swiftpkg_swift_argument_parser -enable-testing -g -module-cache-path bazel-out/darwin_arm64-dbg/bin/_swift_module_cache -static -Onone -D DEBUG -D SWIFT_PACKAGE -D SWIFT_PACKAGE -debug-prefix-map /Applications/Xcode-14.2.0.app/Contents/Developer=DEVELOPER_DIR -file-prefix-map /Applications/Xcode-14.2.0.app/Contents/Developer=DEVELOPER_DIR -debug-prefix-map /private/var/tmp/_bazel_lpadron/9ae9416857eb79bb978de35a53d54970/execroot/cash-ios=. -file-prefix-map /private/var/tmp/_bazel_lpadron/9ae9416857eb79bb978de35a53d54970/execroot/cash-ios=. -new-driver-path /Applications/Xcode-14.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -no-clang-module-breadcrumbs -no-serialize-debugging-options -color-diagnostics -enable-bare-slash-regex -empty-abi-descriptor -resource-dir /Applications/Xcode-14.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -Xcc -Iexternal/swiftpkg_cwlcatchexception/Sources/CwlCatchExceptionSupport/include -Xcc -Ibazel-out/darwin_arm64-dbg/bin/external/swiftpkg_cwlcatchexception/Sources/CwlCatchExceptionSupport/include -Xcc -Ibazel-out/darwin_arm64-dbg/bin/external/swiftpkg_cwlcatchexception/CwlCatchExceptionSupport -Xcc -iquoteexternal/swiftpkg_cwlcatchexception -Xcc -iquotebazel-out/darwin_arm64-dbg/bin/external/swiftpkg_cwlcatchexception -Xcc -iquoteexternal/yams -Xcc -iquotebazel-out/darwin_arm64-dbg/bin/external/yams -Xcc -iquote. -Xcc -iquotebazel-out/darwin_arm64-dbg/bin -Xcc -isystemexternal/yams/Sources/CYaml/include -Xcc -isystembazel-out/darwin_arm64-dbg/bin/external/yams/Sources/CYaml/include -Xcc -DSWIFT_PACKAGE -Xcc -DSWIFT_PACKAGE=1 -Xcc -fmodule-map-file=bazel-out/darwin_arm64-dbg/bin/external/swiftpkg_cwlcatchexception/Sources_CwlCatchExceptionSupport.swift.modulemap -Xcc -fmodule-map-file=bazel-out/darwin_arm64-dbg/bin/external/swiftpkg_cwlcatchexception/Sources_CwlCatchExceptionSupport_modulemap.swift.modulemap -Xcc -fmodule-map-file=bazel-out/darwin_arm64-dbg/bin/external/yams/CYaml.swift.modulemap -Xcc -O0 -Xcc -DDEBUG=1 -Xcc -fstack-protector -Xcc -fstack-protector-all -module-name ModuleWeights -disable-clang-spi -target-sdk-version 13.1 -parse-as-library -o bazel-out/darwin_arm64-dbg/bin/Tools/ModuleWeights/ModuleWeights.library_objs/Sources/ModuleWeights/ModuleGraph+LinesOfCodeSummary.swift.o -o bazel-out/darwin_arm64-dbg/bin/Tools/ModuleWeights/ModuleWeights.library_objs/Sources/ModuleWeights/ModuleLinesOfCodeSummary.swift.o -o bazel-out/darwin_arm64-dbg/bin/Tools/ModuleWeights/ModuleWeights.library_objs/Sources/ModuleWeights/Tool.swift.o To @jpsim comment about -parse-as-library -o bazel-out/darwin_arm64-dbg/bin/Tools/ModuleWeights/ModuleWeights.library_objs/Sources/ModuleWeights/ModuleGraph+LinesOfCodeSummary.swift.o -o bazel-out/darwin_arm64-dbg/bin/Tools/ModuleWeights/ModuleWeights.library_objs/Sources/ModuleWeights/ModuleLinesOfCodeSummary.swift.o -o bazel-out/darwin_arm64-dbg/bin/Tools/ModuleWeights/ModuleWeights.library_objs/Sources/ModuleWeights/Tool.swift.o |
If I remove the rules_swift/swift/internal/compiling.bzl Lines 290 to 293 in dba1542
After a clean and re-build the target compiles successfully. |
That would also explain why I dont see this crash in release builds |
Disabling cahcheable_swiftmodules features seems to be working locally, testing in CI now: features = ["-swift.cacheable_swiftmodules"] |
hrm im not sure why flipping cacheable_swiftmodules would help, maybe this is a different bug |
From your issue in Swift repo it looks like compiler doesnt respect: Edit: Maybe just Xcode 14 bug from this quote:
|
Yea that flag is required to make hermetic swiftmodules since otherwise they contain absolute paths to debug info. So swiftpm doesn't care about that. |
I'm seeing a swiftc compiler crash only when compiling my project with Bazel.
Here's some of the relevant output:
Full output
The fact that this is crashing when generating SIL for
@async_Main
seems pertinent. I haven't seen any similar compiler crashes when building with xcodebuild or SwiftPM on macOS or Linux. Which leads me to believe maybe there's something that's not being done correctly in rules_swift. In particular, maybe the-parse-as-library
trick here doesn't play well withasync @main
?rules_swift/swift/internal/swift_library.bzl
Lines 49 to 73 in 16cac51
Here's a link to the CI jobs where this happened, twice in a row on two different machines before passing again on one of them after retrying: https://buildkite.com/swiftlint/swiftlint/builds/2936#01829956-3d7c-4672-8a63-1c6bf31712fb
Here's the file it's compiling when the crash happens: https://github.com/realm/SwiftLint/blob/15970311e133feb166e2af1de3c2a876012e6575/Source/swiftlint/Commands/SwiftLint.swift
Environment:
The text was updated successfully, but these errors were encountered: