Xcode 11 Segmentation fault: 11 during Archive - swift

I'm receiving a segmentation fault in Xcode 11 when I do an Archive of Generic iOS Device. The file this apparently is occurring in, "InformationMenu", hasn't been touched in months so I have no idea what's causing this.
I've tried making changes to the Optimization Level with no luck. The app builds on devices and simulators which makes this all the more frustrating.
Everything is written in Swift 4, target is iOS 11 and above.
Not sure where to go from here.
InformationMenu.bc
1. While running pass #111377 SILModuleTransform "OwnershipModelEliminator".
0 swift 0x0000000110142eb3 PrintStackTraceSignalHandler(void*) + 51
1 swift 0x0000000110142686 SignalHandler(int) + 358
2 libsystem_platform.dylib 0x00007fff6b1b3b5d _sigtramp + 29
3 libsystem_malloc.dylib 0x00007fff6b174401 tiny_malloc_should_clear + 256
4 swift 0x000000010c4d1cbb (anonymous namespace)::OwnershipModelEliminator::run() + 267
5 swift 0x000000010c441849 swift::SILPassManager::execute() + 7305
6 swift 0x000000010c445c1b swift::runSILDiagnosticPasses(swift::SILModule&) + 2539
7 swift 0x000000010c09de06 swift::CompilerInstance::performSILProcessing(swift::SILModule*, swift::UnifiedStatsReporter*) + 70
8 swift 0x000000010bd99ae5 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 33925
9 swift 0x000000010bd8de54 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6820
10 swift 0x000000010bd1b3c3 main + 1219
11 libdyld.dylib 0x00007fff6afc83d5 start + 1
12 libdyld.dylib 0x00000000000001ab start + 2500034007

Related

Swift compiler crash - anyone seen this?

I have an Obj-C class extending NSObject. One of its properties is an NS_ENUM; let's call it direction.
Then I have a Swift class with an optional property of this Obj-C class; let's call that message.
The following example code is fine:
switch message?.direction
{
case .Inbound:
...
case .OutBound:
...
case nil:
...
}
However, if I then introduce:
guard let message = self.message else { return }
and remove the ? in the code above, the compiler crashes; see below.
It seems to get confused by case nil:, because the crash disappears if I delete it; it's of course no longer needed.
Just curious, has anyone seen this Swift compiler crash?
1. Apple Swift version 5.2 (swiftlang-1103.0.32.1 clang-1103.0.32.29)
2. While emitting IR SIL function "#$s7SomeFunction...".
for 'update()' (at /Users/.../SomeFile.swift:83:11)
0 swift 0x00000001133554ea PrintStackTraceSignalHandler(void*) + 42
1 swift 0x0000000113354cc0 SignalHandler(int) + 352
2 libsystem_platform.dylib 0x00007fff6b8d75fd _sigtramp + 29
3 swift 0x000000010f1aaa4c (anonymous namespace)::SinglePayloadEnumImplStrategy::consume(swift::irgen::IRGenFunction&, swift::irgen::Explosion&, swift::irgen::Atomicity) const + 1244
4 swift 0x00000001131d082c llvm::IRBuilderBase::CreateLifetimeEnd(llvm::Value*, llvm::ConstantInt*) + 28
5 swift 0x000000010f2105a1 swift::irgen::FixedTypeInfo::deallocateStack(swift::irgen::IRGenFunction&, swift::irgen::StackAddress, swift::SILType) const + 81
6 swift 0x000000010f2e8244 swift::SILInstructionVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::SILInstruction*) + 33828
7 swift 0x000000010f2dc8e3 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 8835
8 swift 0x000000010f190032 swift::irgen::IRGenerator::emitGlobalTopLevel() + 1410
9 swift 0x000000010f2baed9 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**) + 1097
10 swift 0x000000010f0b236f 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*) + 4255
11 swift 0x000000010f0a77c0 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 48416
12 swift 0x000000010f01f4d3 main + 1283
13 libdyld.dylib 0x00007fff6b6decc9 start + 1
error: Segmentation fault: 11 (in target 'SomeApp' from project 'SomeApp')

When I archive a iOS project, there has a error: Segmentation fault: 11

MacOS: 10.14.6 - Xcode: Version 11.3.1 (11C504)
I create a demo project in github. if anyone can help me, you can check it
https://github.com/philCc/URLNavigatorExt.git branch:Segmentation_fault_11
1. While running pass #153921 SILFunctionTransform "DCE" on SILFunction "#$s23URLNavigatorExt_Example6RouterO9PRWebviewV8instance2byAESgSDyS2SG_tFZ".
for 'instance(by:)' (at /Users/phil/Documents/WorkSpace/ky_tech/URLNavigatorExt/Example/URLNavigatorExt/generated/Router.generated.swift:989:20)
0 swift 0x000000010e1cca63 PrintStackTraceSignalHandler(void*) + 51
1 swift 0x000000010e1cc236 SignalHandler(int) + 358
2 libsystem_platform.dylib 0x00007fff5b7bfb5d _sigtramp + 29
3 libsystem_platform.dylib 0x000000010f830600 _sigtramp + 3020360384
4 swift 0x000000010a53a370 (anonymous namespace)::DCE::markControllingTerminatorsLive(swift::SILBasicBlock*) + 800
5 swift 0x000000010a539ca2 (anonymous namespace)::DCE::markValueLive(swift::SILNode*) + 466
6 swift 0x000000010a5375e8 (anonymous namespace)::DCE::run() + 2728
7 swift 0x000000010a4bef3e swift::SILPassManager::execute() + 4606
8 swift 0x000000010a11d96b swift::CompilerInstance::performSILProcessing(swift::SILModule*, swift::UnifiedStatsReporter*) + 6379
9 swift 0x0000000109e15ec5 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 33925
10 swift 0x0000000109e0a234 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6820
11 swift 0x0000000109d97733 main + 1219
12 libdyld.dylib 0x00007fff5b5d43d5 start + 1
13 libdyld.dylib 0x0000000000000056 start + 2762128514
error: Segmentation fault: 11 (in target 'URLNavigatorExt_Example' from project 'URLNavigatorExt')
if change the line: 993
then archive will be successful
var _url: String?
// to
var _url: String? = ""
// or
var _url: String? = dict["url"]

How to fix Swift compile issue trap6

The issue happen in Swift3 with XCode10.That maybe be a Swift bug。 Actually,clean and rebuild can solve the issue,but that wast too much time。Any body know a effect way to solve or avoid the issue。Thank you
** DESERIALIZATION FAILURE (please include this section in any bug report) ***
could not deserialize type for '_': could not deserialize type for 'operImageView': top-level value not found
Cross-reference to module 'LKImageKit'
... LKImageView
0 swift 0x000000010460f59a PrintStackTraceSignalHandler(void*) + 42
1 swift 0x000000010460ed4e SignalHandler(int) + 302
2 libsystem_platform.dylib 0x00007fff5e91df5a _sigtramp + 26
3 libsystem_platform.dylib 0x00007fe96482b200 _sigtramp + 99668672
4 libsystem_c.dylib 0x00007fff5e6bb1ae abort + 127
5 swift 0x0000000101a74feb swift::ModuleFile::fatal(llvm::Error) + 1915
6 swift 0x0000000101aac643 getSILDeclRef(swift::ModuleFile*, llvm::ArrayRef<unsigned long long>, unsigned int&) + 307
7 swift 0x0000000101aae984 swift::SILDeserializer::readVTable(llvm::PointerEmbeddedInt<unsigned int, 31>) + 740
8 swift 0x0000000101b5576b swift::SerializedSILLoader::getAllForModule(swift::Identifier, swift::FileUnit*) + 331
9 swift 0x000000010089d92e performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 34558
10 swift 0x0000000100891d35 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7717
11 swift 0x0000000100837965 main + 1349
12 libdyld.dylib 0x00007fff5e60f015 start + 1
WSRecommendHeaderCollectionReusableView~partial.swiftmodule
/Users/levinyang/Library/Developer/Xcode/DerivedData/myProject-hgotlvyrysfhcyeakqaatptobuxm/Build/Intermediates.noindex/myProject.build/Debug-iphoneos/myProject.build/Objects-normal/arm64/WSActionSheetRecommendFlowHandler~partial.swiftmodule
---
2. While deserializing SIL vtable for 'WSNotificationOperCell' in module 'myProject'
** DESERIALIZATION FAILURE (please include this section in any bug report) ***
could not deserialize type for '_': could not deserialize type for 'operImageView': top-level value not found
Cross-reference to module 'LKImageKit'
... LKImageView
0 swift 0x000000010460f59a PrintStackTraceSignalHandler(void*) + 42
1 swift 0x000000010460ed4e SignalHandler(int) + 302
2 libsystem_platform.dylib 0x00007fff5e91df5a _sigtramp + 26
3 libsystem_platform.dylib 0x00007fe96482b200 _sigtramp + 99668672
4 libsystem_c.dylib 0x00007fff5e6bb1ae abort + 127
5 swift 0x0000000101a74feb swift::ModuleFile::fatal(llvm::Error) + 1915
6 swift 0x0000000101aac643 getSILDeclRef(swift::ModuleFile*, llvm::ArrayRef<unsigned long long>, unsigned int&) + 307
7 swift 0x0000000101aae984 swift::SILDeserializer::readVTable(llvm::PointerEmbeddedInt<unsigned int, 31>) + 740
8 swift 0x0000000101b5576b swift::SerializedSILLoader::getAllForModule(swift::Identifier, swift::FileUnit*) + 331
9 swift 0x000000010089d92e performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 34558
10 swift 0x0000000100891d35 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7717
11 swift 0x0000000100837965 main + 1349
12 libdyld.dylib 0x00007fff5e60f015 start + 1
WSRecommendHeaderCollectionReusableView~partial.swiftmodule
/Users/levinyang/Library/Developer/Xcode/DerivedData/myProject-hgotlvyrysfhcyeakqaatptobuxm/Build/Intermediates.noindex/myProject.build/Debug-iphoneos/myProject.build/Objects-normal/arm64/WSActionSheetRecommendFlowHandler~partial.swiftmodule
---
2. While deserializing SIL vtable for 'WSNotificationOperCell' in module 'myProject'
error: Abort trap: 6
This is a Swift compiler bug. It's possible that you're triggering it by linking modules that were compiled by different versions of the compiler, or some other unsupported behavior, but it probably still shouldn't crash.
However, you say it's a Swift 3 problem. The Swift developers no longer support Swift 3. They are working on Swift 5. If you can reproduce the problem in Swift 5, you can file a bug report at https://bugs.swift.org.

Run shell script from Package.swift

I'm trying to include a hardcoded version string generated by git describe within a CLI I'm writing in Swift.
The idea was to have a shell script that executes git describe and writes that as a global constant into a file called Version.swift, which I can then reference from within my tool.
I don't want to have to think about running this script before every build though or building the project via another shell script. The ideal way would be to keep using swift build and having Swift itself invoke said script when it compiles and evaluates Package.swift.
So I included the following in my package manifest.
import Foundation
let task = Process()
task.launchPath = "./"
task.arguments = ["update_version.sh"]
task.launch()
task.waitUntilExit()
Whilst importing Foundation and initializing the task seems to work just fine, actually launching it crashes and outputs the following stack trace.
error: manifest parse error(s):
2017-07-28 15:07:43.711 swift[39828:16163314] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Couldn't posix_spawn: error 13'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff9be232cb __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fffb0c5d48d objc_exception_throw + 48
2 CoreFoundation 0x00007fff9bea1c3d +[NSException raise:format:] + 205
3 Foundation 0x00007fff9d84c54e -[NSConcreteTask launchWithDictionary:] + 3134
4 ??? 0x0000000109ccb1c3 0x0 + 4459377091
5 swift 0x00000001045fe84f _ZN4llvm5MCJIT11runFunctionEPNS_8FunctionENS_8ArrayRefINS_12GenericValueEEE + 655
6 swift 0x0000000104604ab3 _ZN4llvm15ExecutionEngine17runFunctionAsMainEPNS_8FunctionERKNSt3__16vectorINS3_12basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEENS8_ISA_EEEEPKPKc + 707
7 swift 0x00000001039f4512 _ZL14performCompileRN5swift16CompilerInstanceERNS_18CompilerInvocationEN4llvm8ArrayRefIPKcEERiPNS_16FrontendObserverEPNS_20UnifiedStatsReporterE + 22802
8 swift 0x00000001039ed394 _ZN5swift15performFrontendEN4llvm8ArrayRefIPKcEES3_PvPNS_16FrontendObserverE + 7332
9 swift 0x00000001039a2ad8 main + 12248
10 libdyld.dylib 0x00007fffb1542235 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
0 swift 0x0000000107073eaa PrintStackTraceSignalHandler(void*) + 42
1 swift 0x00000001070732e6 SignalHandler(int) + 662
2 libsystem_platform.dylib 0x00007fffb1751b3a _sigtramp + 26
3 libsystem_platform.dylib 0x00000003ba442240 _sigtramp + 147785504
4 libsystem_c.dylib 0x00007fffb15d6420 abort + 129
5 libc++abi.dylib 0x00007fffb012c84a __cxa_bad_cast + 0
6 libc++abi.dylib 0x00007fffb0151c4f default_unexpected_handler() + 0
7 libobjc.A.dylib 0x00007fffb0c5f6fe _objc_terminate() + 103
8 libc++abi.dylib 0x00007fffb014ed69 std::__terminate(void (*)()) + 8
9 libc++abi.dylib 0x00007fffb014e9f2 __cxa_rethrow + 99
10 libobjc.A.dylib 0x00007fffb0c5d94a objc_exception_rethrow + 40
11 Foundation 0x00007fff9d84c884 -[NSConcreteTask launchWithDictionary:] + 3956
12 Foundation 0x0000000109ccb1c3 -[NSConcreteTask launchWithDictionary:] + 1816656051
13 swift 0x00000001045fe84f llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) + 655
14 swift 0x0000000104604ab3 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*) + 707
15 swift 0x00000001039f4512 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 22802
16 swift 0x00000001039ed394 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7332
17 swift 0x00000001039a2ad8 main + 12248
18 libdyld.dylib 0x00007fffb1542235 start + 1
Stack dump:
0. Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret /Users/kilian/dev/apodidae/Package.swift -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -I /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4 -swift-version 4 -module-name Package -lPackageDescription -- -fileno 5
The content of update_version.sh is the following
echo "// THIS FILE IS AUTO-GENERATED\npublic let VERSION = \""$(git describe)"\"" > Sources/target/Version.swift
What could I do here to get this to work? Does this have to do with the package manifest being executed within a sandbox? And if so, what options do I have to accomplish what I'm trying to do? If in any way possible I'd really love to just run swift build and have the rest just work.
the exception has NOTHING with your approach, the system raised it because your launchPath is NOT a valid launch path :-). You have to be ABSOLUTELY sure about the validity of your launchPath, otherwise, the execution will be terminated with some uncaught exception. For a solution see how to solve it

Xcode 7 and Swift 2.0 : Command failed due to signal: Abort trap: 6

Since Xcode 7 and Swift 2.0, in my current project, I get the error above :
Assertion failed: (Conformance.size() == Archetype->getConformsTo().size() && "substitution conformances don't match archetype"), function Substitution, file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-700.0.38.1/src/swift/lib/AST/Substitution.cpp, line 64.
0 swift 0x0000000111d84e0b llvm::sys::PrintStackTrace(__sFILE*) + 43
1 swift 0x0000000111d8554b SignalHandler(int) + 379
2 libsystem_platform.dylib 0x00007fff8bcc7f1a _sigtramp + 26
3 libsystem_platform.dylib 000000000000000000 _sigtramp + 1949532416
4 libsystem_c.dylib 0x00007fff89e58b53 abort + 129
5 libsystem_c.dylib 0x00007fff89e20c39 basename + 0
6 swift 0x0000000110557c9f swift::Substitution::Substitution(swift::ArchetypeType*, swift::Type, llvm::ArrayRef<swift::ProtocolConformance*>) + 271
7 swift 0x0000000110269fa0 swift::SILCloner<swift::SILInliner>::getOpConformances(swift::ArchetypeType*, swift::CanType, llvm::ArrayRef<swift::ProtocolConformance*>) + 256
8 swift 0x0000000110263235 swift::SILCloner<swift::SILInliner>::visitInitExistentialRefInst(swift::InitExistentialRefInst*) + 133
9 swift 0x000000011025831b swift::SILCloner<swift::SILInliner>::visitSILBasicBlock(swift::SILBasicBlock*) + 75
10 swift 0x00000001102574e1 swift::SILInliner::inlineFunction(swift::FullApplySite, llvm::ArrayRef<swift::SILValue>) + 897
11 swift 0x00000001100c92d3 (anonymous namespace)::SILPerformanceInlinerPass::run() + 9427
12 swift 0x000000011007d9a8 swift::SILPassManager::runOneIteration() + 2072
13 swift 0x000000011007a4c8 swift::runSILOptimizationPasses(swift::SILModule&) + 424
14 swift 0x000000010fd9e83f performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 9583
15 swift 0x000000010fd9c0b3 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2515
16 swift 0x000000010fd9828f main + 1983
17 libdyld.dylib 0x00007fff87ca05c9 start + 1
Stack dump:
If I set the Optimisation Level to "None", it works, but with optimisation ( by default), it shows me this.