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
[SR-7879] UIEdgeInsets.zero use crashes Xcode 10/Swift 4.2 compiler #50414
Comments
Alternatively, replace it with
The crash reads in part: MergeSwiftModule normal x86_64
*** DESERIALIZATION FAILURE (please include this section in any bug report) ***
result is ambiguous
0 swift 0x0000000109540c5a PrintStackTraceSignalHandler(void*) + 42
1 swift 0x0000000109540066 SignalHandler(int) + 966
2 libsystem_platform.dylib 0x00007fff7e535f5a _sigtramp + 26
3 libsystem_platform.dylib 000000000000000000 _sigtramp + 2175574208
4 libsystem_c.dylib 0x00007fff7e2d31ae abort + 127
5 swift 0x00000001069e699b swift::ModuleFile::fatal(llvm::Error) + 1915
6 swift 0x0000000106a1e4d2 swift::SILDeserializer::readGlobalVar(llvm::StringRef) + 1890
7 swift 0x0000000106ac8f9a swift::SerializedSILLoader::getAllForModule(swift::Identifier, swift::FileUnit*) + 234
8 swift 0x000000010581bdbe performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 34750
9 swift 0x000000010581010f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7839
10 swift 0x00000001057b9c48 main + 13144
11 libdyld.dylib 0x00007fff7e227015 start + 1
1. While deserializing SIL global "UIEdgeInsetsZero"
error: Abort trap: 6 |
Thanks, Dave and Matt! |
Comment by Bobby Ren (JIRA) I worked with Max at WWDC and we were able to reproduce this with a fresh project created in Xcode 10. <unknown>:0: error: fatal error encountered while reading from module 'Test2'; please file a bug report with your project and the crash log
*** DESERIALIZATION FAILURE (please include this section in any bug report) ***
result is ambiguous
0 swift 0x000000010867ac5a PrintStackTraceSignalHandler(void*) + 42
1 swift 0x000000010867a066 SignalHandler(int) + 966
2 libsystem_platform.dylib 0x00007fff7ea4ef5a _sigtramp + 26
3 libsystem_platform.dylib 000000000000000000 _sigtramp + 2170228928
4 libsystem_c.dylib 0x00007fff7e7ec1ae abort + 127
5 swift 0x0000000105b2099b swift::ModuleFile::fatal(llvm::Error) + 1915
6 swift 0x0000000105b584d2 swift::SILDeserializer::readGlobalVar(llvm::StringRef) + 1890
7 swift 0x0000000105c02f9a swift::SerializedSILLoader::getAllForModule(swift::Identifier, swift::FileUnit*) + 234
8 swift 0x0000000104955dbe performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 34750
9 swift 0x000000010494a10f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7839
10 swift 0x00000001048f3c48 main + 13144
11 libdyld.dylib 0x00007fff7e740015 start + 1
12 libdyld.dylib 0x0000000000000040 start + 2173435948
Stack dump:
0. Program arguments: /Users/bren200/Downloads/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -merge-modules -emit-module /Users/bren200/Library/Developer/Xcode/DerivedData/Test2-azqhapnmgemxarbrndxkhgtjvvij/Build/Intermediates.noindex/Test2.build/Debug-iphonesimulator/Test2.build/Objects-normal/x86_64/ViewController~partial.swiftmodule /Users/bren200/Library/Developer/Xcode/DerivedData/Test2-azqhapnmgemxarbrndxkhgtjvvij/Build/Intermediates.noindex/Test2.build/Debug-iphonesimulator/Test2.build/Objects-normal/x86_64/AppDelegate~partial.swiftmodule -parse-as-library -sil-merge-partial-modules -disable-diagnostic-passes -disable-sil-perf-optzns -target x86_64-apple-ios12.0-simulator -enable-objc-interop -sdk /Users/bren200/Downloads/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk -I /Users/bren200/Library/Developer/Xcode/DerivedData/Test2-azqhapnmgemxarbrndxkhgtjvvij/Build/Products/Debug-iphonesimulator -F /Users/bren200/Library/Developer/Xcode/DerivedData/Test2-azqhapnmgemxarbrndxkhgtjvvij/Build/Products/Debug-iphonesimulator -enable-testing -g -module-cache-path /Users/bren200/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 4.2 -enforce-exclusivity=checked -Onone -D DEBUG -serialize-debugging-options -Xcc -working-directory -Xcc /Users/bren200/Desktop/Projects/Test2 -Xcc -I/Users/bren200/Library/Developer/Xcode/DerivedData/Test2-azqhapnmgemxarbrndxkhgtjvvij/Build/Intermediates.noindex/Test2.build/Debug-iphonesimulator/Test2.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/bren200/Library/Developer/Xcode/DerivedData/Test2-azqhapnmgemxarbrndxkhgtjvvij/Build/Intermediates.noindex/Test2.build/Debug-iphonesimulator/Test2.build/Test2-generated-files.hmap -Xcc -I/Users/bren200/Library/Developer/Xcode/DerivedData/Test2-azqhapnmgemxarbrndxkhgtjvvij/Build/Intermediates.noindex/Test2.build/Debug-iphonesimulator/Test2.build/Test2-own-target-headers.hmap -Xcc -I/Users/bren200/Library/Developer/Xcode/DerivedData/Test2-azqhapnmgemxarbrndxkhgtjvvij/Build/Intermediates.noindex/Test2.build/Debug-iphonesimulator/Test2.build/Test2-all-target-headers.hmap -Xcc -iquote -Xcc /Users/bren200/Library/Developer/Xcode/DerivedData/Test2-azqhapnmgemxarbrndxkhgtjvvij/Build/Intermediates.noindex/Test2.build/Debug-iphonesimulator/Test2.build/Test2-project-headers.hmap -Xcc -I/Users/bren200/Library/Developer/Xcode/DerivedData/Test2-azqhapnmgemxarbrndxkhgtjvvij/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/bren200/Library/Developer/Xcode/DerivedData/Test2-azqhapnmgemxarbrndxkhgtjvvij/Build/Intermediates.noindex/Test2.build/Debug-iphonesimulator/Test2.build/DerivedSources/x86_64 -Xcc -I/Users/bren200/Library/Developer/Xcode/DerivedData/Test2-azqhapnmgemxarbrndxkhgtjvvij/Build/Intermediates.noindex/Test2.build/Debug-iphonesimulator/Test2.build/DerivedSources -Xcc -DDEBUG=1 -emit-module-doc-path /Users/bren200/Library/Developer/Xcode/DerivedData/Test2-azqhapnmgemxarbrndxkhgtjvvij/Build/Intermediates.noindex/Test2.build/Debug-iphonesimulator/Test2.build/Objects-normal/x86_64/Test2.swiftdoc -emit-objc-header-path /Users/bren200/Library/Developer/Xcode/DerivedData/Test2-azqhapnmgemxarbrndxkhgtjvvij/Build/Intermediates.noindex/Test2.build/Debug-iphonesimulator/Test2.build/Objects-normal/x86_64/Test2-Swift.h -module-name Test2 -o /Users/bren200/Library/Developer/Xcode/DerivedData/Test2-azqhapnmgemxarbrndxkhgtjvvij/Build/Intermediates.noindex/Test2.build/Debug-iphonesimulator/Test2.build/Objects-normal/x86_64/Test2.swiftmodule
1. While deserializing SIL global "UIEdgeInsetsZero"
error: Abort trap: 6 |
The workaround right now is what Dave put in the original report: don't use UIEdgeInsets.zero. |
Comment by Anisov Aleksey (JIRA) Hi, @belkadan I don't know why it doesn't work for me, still have a crash. Maybe dependencies influence it? |
And the crash still says "UIEdgeInsetsZero" at the end? Hm. I don't have any other suggestions without being able to see your code. (I know that if it were my code, though, I would have missed a |
@belkadan In my case that's exactly what happened in another project: I got the crash, it said UIEdgeInsetsZero, I searched on |
Comment by Anisov Aleksey (JIRA) @belkadan I have found the code contentInset = .zero 🙂 now all works, sorry |
FYI, here the workaround I'm using (avoids hunting around for all the usage sites in your app): #if swift(>=4.2)
// Workaround for https://bugs.swift.org/browse/SR-7879
extension UIEdgeInsets {
static let zero = UIEdgeInsets()
}
#endif |
This also appears to be an issue with UIOffset, I assume it's related. |
There are two declarations named ‘zero’ in UIEdgeInsets. One is an imported global variable, renamed to a member via API notes. The other is defined in the UIKit overlay, as a computed property in Swift. The serialization xref does not encode enough information to distinguish the two. |
This part of filterValues() doesn’t make sense — why are we ignoring the module filter if the declaration was imported? If I remove this part, we no longer crash with this .zero thing:
|
Comment by tyeen (JIRA) Just an additional information, I've encountered the same error, and if I switched to "Whole Module" in "Compilation Mode", the building could pass successfully. |
@Slava: Removing that would be an incorrect fix since we really do want the one from UIKit proper, and not the overlay. There's a whole pile of badness here, really, but as far as a fix for Swift 4.2 goes I have a hack that I've already run by Doug and Max. I do want to check in with the UIKit folks before I land it, though. |
yeen (JIRA User): Yep, in most cases that will avoid the bug, but not all. (Inlinable code that references UIEdgeInsets.zero is the other major cause.) |
Hack, as promised: #17122 |
Environment
macOS 10.14 and Xcode 10 initial betas
Additional Detail from JIRA
md5: 5d11bc68b440e1aeef6aca544f835a80
is duplicated by:
error: Abort trap: 6
statusrelates to:
Issue Description:
UIEdgeInsets.zero crashes compiler. Replacing that with UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) allows the code to compile.
The text was updated successfully, but these errors were encountered: