07-18-2023, 06:50 PM
I got segmentation fault on my Mac Mini using Xcode Bots. The seg fault did only occur during build step of testing and not during building or running locally. Only in Xcode bots during build step of testing.
I am using macOS Sierra and Xcode 8, with the code converted to Swift 2.3.
I finally found the line causing the seg fault, it was caused by:
public let isIpad = UIDevice.currentDevice().userInterfaceIdiom == .Pad
Which was declared outside a class as a constant. Changing it to check the userInterfaceIdiom at runtime fixed the issue.
Hopes this helps someone else!
This is the error log for my seg fault:
0 swift 0x000000010f93d76b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1 swift 0x000000010f93ca56 llvm::sys::RunSignalHandlers() + 70
2 swift 0x000000010f93ddbf SignalHandler(int) + 287
3 libsystem_platform.dylib 0x00007fffb24aabba _sigtramp + 26
4 libsystem_platform.dylib 0x00007fbbfff49ae0 _sigtramp + 1302982464
5 swift 0x000000010db79996 (anonymous namespace)::Traversal::visit(swift::Expr*) + 118
6 swift 0x000000010db7b880 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 128
7 swift 0x000000010db799eb (anonymous namespace)::Traversal::visit(swift::Expr*) + 203
8 swift 0x000000010db78f45 swift::Expr::walk(swift::ASTWalker&) + 53
9 swift 0x000000010d6d2c87 walkForProfiling(swift::AbstractFunctionDecl*, swift::ASTWalker&) + 231
10 swift 0x000000010d6d2719 swift::Lowering::SILGenProfiling::assignRegionCounters(swift::AbstractFunctionDecl*) + 553
11 swift 0x000000010d6de348 (anonymous namespace)::SILGenType::emitType() + 952
12 swift 0x000000010d6ddf1e swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 30
13 swift 0x000000010d6625eb swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 731
14 swift 0x000000010d663139 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 793
15 swift 0x000000010d6635a3 swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&, llvm::Optional<unsigned int>, bool) + 115
16 swift 0x000000010d491c18 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 12536
17 swift 0x000000010d48dc79 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2777
18 swift 0x000000010d489765 main + 1957
19 libdyld.dylib 0x00007fffb229e255 start + 1
I am using macOS Sierra and Xcode 8, with the code converted to Swift 2.3.
I finally found the line causing the seg fault, it was caused by:
public let isIpad = UIDevice.currentDevice().userInterfaceIdiom == .Pad
Which was declared outside a class as a constant. Changing it to check the userInterfaceIdiom at runtime fixed the issue.
Hopes this helps someone else!
This is the error log for my seg fault:
0 swift 0x000000010f93d76b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1 swift 0x000000010f93ca56 llvm::sys::RunSignalHandlers() + 70
2 swift 0x000000010f93ddbf SignalHandler(int) + 287
3 libsystem_platform.dylib 0x00007fffb24aabba _sigtramp + 26
4 libsystem_platform.dylib 0x00007fbbfff49ae0 _sigtramp + 1302982464
5 swift 0x000000010db79996 (anonymous namespace)::Traversal::visit(swift::Expr*) + 118
6 swift 0x000000010db7b880 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 128
7 swift 0x000000010db799eb (anonymous namespace)::Traversal::visit(swift::Expr*) + 203
8 swift 0x000000010db78f45 swift::Expr::walk(swift::ASTWalker&) + 53
9 swift 0x000000010d6d2c87 walkForProfiling(swift::AbstractFunctionDecl*, swift::ASTWalker&) + 231
10 swift 0x000000010d6d2719 swift::Lowering::SILGenProfiling::assignRegionCounters(swift::AbstractFunctionDecl*) + 553
11 swift 0x000000010d6de348 (anonymous namespace)::SILGenType::emitType() + 952
12 swift 0x000000010d6ddf1e swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 30
13 swift 0x000000010d6625eb swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 731
14 swift 0x000000010d663139 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 793
15 swift 0x000000010d6635a3 swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&, llvm::Optional<unsigned int>, bool) + 115
16 swift 0x000000010d491c18 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 12536
17 swift 0x000000010d48dc79 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2777
18 swift 0x000000010d489765 main + 1957
19 libdyld.dylib 0x00007fffb229e255 start + 1