Skip to content
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

Closed
swift-ci opened this issue Jun 5, 2018 · 16 comments
Closed

[SR-7879] UIEdgeInsets.zero use crashes Xcode 10/Swift 4.2 compiler #50414

swift-ci opened this issue Jun 5, 2018 · 16 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself serialization Area → compiler: Serialization & deserialization

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jun 5, 2018

Previous ID SR-7879
Radar rdar://problem/40735990
Original Reporter dave256 (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

macOS 10.14 and Xcode 10 initial betas

Additional Detail from JIRA
Votes 10
Component/s Compiler
Labels Bug, Serialization
Assignee None
Priority Medium

md5: 5d11bc68b440e1aeef6aca544f835a80

is duplicated by:

  • SR-7892 Swift compiler crashes with error: Abort trap: 6 status
  • SR-7893 Compiler error when building for Swift 4.2 in Xcode 10 beta
  • SR-7966 Migrating issues
  • SR-8062 error: fatal error encountered while reading from module 'CompuLEAD'; please file a bug report with your project and the crash log
  • SR-7947 Xcode 10: Trap 6 in Merge swiftmodule

relates to:

  • SR-8149 NSPasteboard.PasteboardType.findPanelSearchOptions crashes compiler

Issue Description:

UIEdgeInsets.zero crashes compiler. Replacing that with UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) allows the code to compile.

@mattneub
Copy link

mattneub commented Jun 5, 2018

Alternatively, replace it with UIEdgeInsets().

.zero is still documented, so the need to make this change seems like a bug.

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

@belkadan
Copy link
Contributor

belkadan commented Jun 5, 2018

Thanks, Dave and Matt!

@swift-ci
Copy link
Collaborator Author

swift-ci commented Jun 5, 2018

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

@belkadan
Copy link
Contributor

belkadan commented Jun 6, 2018

The workaround right now is what Dave put in the original report: don't use UIEdgeInsets.zero.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Jun 6, 2018

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?

@belkadan
Copy link
Contributor

belkadan commented Jun 6, 2018

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 .zero somewhere.)

@mattneub
Copy link

mattneub commented Jun 6, 2018

@belkadan In my case that's exactly what happened in another project: I got the crash, it said UIEdgeInsetsZero, I searched on zero and found it, I fixed it. Gotta say, what a great crash log! Tells you just what to do. Makes me happy.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Jun 7, 2018

Comment by Anisov Aleksey (JIRA)

@belkadan I have found the code

contentInset = .zero

🙂 now all works, sorry

@nicklockwood
Copy link
Contributor

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

@keith
Copy link
Collaborator

keith commented Jun 9, 2018

This also appears to be an issue with UIOffset, I assume it's related.

@slavapestov
Copy link
Member

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.

@slavapestov
Copy link
Member

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:

     // FIXME: Should be able to move a value from an extension in a derived
     // module to the original definition in a base module.
     if (expectedModule && !value->hasClangNode() &&

@swift-ci
Copy link
Collaborator Author

swift-ci commented Jun 9, 2018

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.

@belkadan
Copy link
Contributor

@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.

@belkadan
Copy link
Contributor

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.)

@belkadan
Copy link
Contributor

Hack, as promised: #17122

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself serialization Area → compiler: Serialization & deserialization
Projects
None yet
Development

No branches or pull requests

6 participants