Open swift-ci opened 4 years ago
Comment by Ondrej Hanslik (JIRA)
It also crashes for me, I have a completely different script, the crash trace is the same. A script with a single `print` works fine but most other commands crash the compiler (e.g. creating `URL` from a string).
Comment by Peter Steinberger (JIRA)
We're hitting this as well after updating from Xcode 11.3.1 to Xcode 11.4.
Stack dump:
0. Program arguments: /Applications/Xcode-11.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret /Users/Adrian/Projects/pspdfkit/pspdfkit/iOS/PSPDFKit/../bin/UpdateLocalizedStringKeys.swift -enable-objc-interop -stack-check -sdk /Applications/Xcode-11.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -module-name UpdateLocalizedStringKeys -- -strings /Users/Adrian/Projects/pspdfkit/pspdfkit/iOS/PSPDFKit/PSPDFKit.bundle/en.lproj/PSPDFKit.strings -stringsdict /Users/Adrian/Projects/pspdfkit/pspdfkit/iOS/PSPDFKit/PSPDFKit.bundle/en.lproj/PSPDFKit.stringsdict -objc /Users/Adrian/Projects/pspdfkit/pspdfkit/iOS/PSPDFKit/Localization/PSPDFLocalizedStringKeys.h
1. Apple Swift version 5.2 (swiftlang-1103.0.32.1 clang-1103.0.32.29)
2. While running user code "/Users/Adrian/Projects/pspdfkit/pspdfkit/iOS/PSPDFKit/../bin/UpdateLocalizedStringKeys.swift"
0 swift 0x000000010ab224ea PrintStackTraceSignalHandler(void*) + 42
1 swift 0x000000010ab21cc0 SignalHandler(int) + 352
2 libsystem_platform.dylib 0x00007fff675e15fd _sigtramp + 29
3 libsystem_platform.dylib 0x000000010c302c00 _sigtramp + 2765231648
4 libsystem_platform.dylib 0x000000010e843020 _sigtramp + 2804292160
5 swift 0x00000001068a59ba llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) + 458
6 swift 0x00000001068aca2b llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, char const* const*) + 2011
7 swift 0x0000000106881aea performCompileStepsPostSILGen(swift::CompilerInstance&, swift::CompilerInvocation&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, bool, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, bool, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 14362
8 swift 0x00000001068764a5 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 55813
9 swift 0x00000001067ec4d3 main + 1283
10 libdyld.dylib 0x00007fff673e8cc9 start + 1
/Users/Adrian/Library/Developer/Xcode/DerivedData/PSPDFKit-hcfwhbqsbrlekyhffzenhcscpmmm/Build/Intermediates.noindex/PSPDFKit.build/Debug-iphonesimulator/UpdateGeneratedSources.build/Script-A57337B223D7B18D00737748.sh: line 2: 13873 Segmentation fault: 11 /usr/bin/env xcrun --sdk macosx swift "${PROJECT_DIR}/../bin/UpdateLocalizedStringKeys.swift" -strings "${SRCROOT}/PSPDFKit.bundle/en.lproj/PSPDFKit.strings" -stringsdict "${SRCROOT}/PSPDFKit.bundle/en.lproj/PSPDFKit.stringsdict" -objc "${SRCROOT}/Localization/PSPDFLocalizedStringKeys.h"
Command PhaseScriptExecution failed with a nonzero exit code
Comment by Igor Kulman (JIRA)
Same problem in my script, but I found a workaround: compiling the script and running the binary works. So instead of `swift script.swift` I do `swiftc script.swift && ./script && rm script`
What dylibs are loaded into the crashed swift process? You could look at the generated crash logs to find out. @xymus noticed that in some previous reproductions of this issue, there were Brew projects that had installed their own versions of the Swift overlays into /usr/local/Cellar, which will cause all sorts of havoc.
Comment by Ondrej Hanslik (JIRA)
Added a crash log.
Thanks Ondrej! In the crash log, I see:
0x115515000 - 0x115524ff7 +libswiftCoreGraphics.dylib (4.2.1 - 1000.11.42) <579D172D-0873-33EB-A529-742D5D70BD74> /usr/local/Cellar/swiftgen/6.1.0/lib/libswiftCoreGraphics.dylib
0x115549000 - 0x11554cfff +libswiftIOKit.dylib (4.2.1 - 1000.11.42) <575A9454-3EB8-3314-B67B-9D0C88C03D5F> /usr/local/Cellar/swiftgen/6.1.0/lib/libswiftIOKit.dylib
0x115554000 - 0x115557fff +libswiftCoreFoundation.dylib (4.2.1 - 1000.11.42) <801E1416-6C23-3C48-BF46-2349B9F36C9E> /usr/local/Cellar/swiftgen/6.1.0/lib/libswiftCoreFoundation.dylib
0x11555e000 - 0x115566fff +libswiftDarwin.dylib (4.2.1 - 1000.11.42) <70D5D45B-0327-352C-BDCE-F792699DAB88> /usr/local/Cellar/swiftgen/6.1.0/lib/libswiftDarwin.dylib
0x117350000 - 0x1174b8fff +libswiftFoundation.dylib (4.2.1 - 1000.11.42) <2252DB9E-6B26-31AD-A869-9D92FA2BE196> /usr/local/Cellar/swiftgen/6.1.0/lib/libswiftFoundation.dylib
0x117654000 - 0x1179e6ff7 +libswiftCore.dylib (4.2.1 - 1000.11.42) <D0C86227-BFC8-30D7-93B8-9F228E0F15BA> /usr/local/Cellar/swiftgen/6.1.0/lib/libswiftCore.dylib
0x117cba000 - 0x117cd3ff7 +libswiftDispatch.dylib (4.2.1 - 1000.11.42) <E8DBE923-0513-3FE8-8E3A-5778014FD810> /usr/local/Cellar/swiftgen/6.1.0/lib/libswiftDispatch.dylib
0x117d12000 - 0x117d16fff +libswiftObjectiveC.dylib (4.2.1 - 1000.11.42) <A521AAA2-3B1F-38AF-BFA0-BB02A94ECA8B> /usr/local/Cellar/swiftgen/6.1.0/lib/libswiftObjectiveC.dylib
0x117d21000 - 0x117d24fff +libswiftXPC.dylib (4.2.1 - 1000.11.42) <3EC739CE-A1AC-3199-8461-9CA872E2B9EF> /usr/local/Cellar/swiftgen/6.1.0/lib/libswiftXPC.dylib
Does the problem go away if you remove these rogue overlay dylibs?
Comment by Nikolaj (JIRA)
I have the same issue, and removing the dylibs from SwiftGen does fix the issue, but that breaks SwiftGen
Comment by Nikolaj (JIRA)
Reinstalling SwiftGen from Homebrew with "--build-from-source" and removing the dylibs from the "lib" folder seems to work
Comment by Michal Srutek (JIRA)
I can confirm that Tørring (JIRA User) 's solution does seem to work for me.
Comment by Ondrej Hanslik (JIRA)
I cannot confirm since I had to downgrade my Xcode but the script works on my second laptop where SwiftGen was never installed.
However, I am still baffled why `swift script` works differently than `swiftc script && ./script`.
Attachment: Download
Environment
MacOS 10.15.3 Apple Swift version 5.2 (swiftlang-1103.0.32.1 clang-1103.0.32.29)Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 10 | |Component/s | Compiler | |Labels | Bug, 5.1Regression, CompilerCrash | |Assignee | None | |Priority | Medium | md5: 07e2368c7e176563c97c142ec9826f10Issue Description:
I've got a custom Swift script that is similar to the following:
On Swift 5.1 and lower it runs just fine, but upon updating to Swift 5.2, I get
Is this a bug, or am I doing something wrong?