swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.59k stars 10.37k forks source link

[SR-5330] Swift 4 Segmentation Faults Constantly on Realm #47904

Closed swift-ci closed 7 years ago

swift-ci commented 7 years ago
Previous ID SR-5330
Radar rdar://problem/32677610
Original Reporter JeSuisLuis (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment ``` none Model Name: iMac Model Identifier: iMac17,1 Processor Name: Intel Core i5 Processor Speed: 3.2 GHz Number of Processors: 1 Total Number of Cores: 4 L2 Cache (per Core): 256 KB L3 Cache: 6 MB Memory: 24 GB Boot ROM Version: IM171.0105.B20 SMC Version (system): 2.33f10 Realm version 2.8.3 Xcode 9 Beta 2 Cocoapods 1.3.0.beta.2 Podfile: platform :ios, '9.0' use_frameworks! inhibit_all_warnings! def all_pods pod 'RealmSwift' pod 'UICircularProgressRing' pod 'UIEmptyState' pod 'LPIntegratedRating' end target 'GradePoint' do all_pods end target 'GradePointTests' do all_pods end target 'GradePointUITests' do all_pods end post_install do |installer| installer.pods_project.targets.each do |target| puts target.name target.build_configurations.each do |config| config.build_settings['SWIFT_VERSION'] = ‘4.0’ end end end ```
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, 4.0Regression, CompilerCrash, Serialization | |Assignee | None | |Priority | Medium | md5: cbfd64381e21f6216f34f44c12e8c9b2

Issue Description:

Since upgrading to Swift 4 and Xcode 9 Beta 2. The amount of segfaults I have received have increased tenfold. At this point the compiler is segfaulting for simple spelling mistakes. There are no actual errors given just the basic
Command failed due to signal: Segmentation fault: 11 error.

Not exactly sure what is causing all these segfaults but I have noticed that Realm seems be involved in causing these. Removing my import for RealmSwift when the compiler has segfaulted and rebuilding seems to generate actual error messages and such.

Here is a log of a segfault where spelling statu as status inside a switch caused a segfault:

CompileSwift normal x86_64 

1.  While type-checking 'ratingViewDidFinish' at /Users/luis/Programming/iOS/GradePoint/GradePoint/ClassesTableViewController.swift:865:5
2.  While type-checking expression at [/Users/luis/Programming/iOS/GradePoint/GradePoint/ClassesTableViewController.swift:866:16 - line:866:16] RangeText="s"
3.  While reading from /Users/luis/Library/Developer/Xcode/DerivedData/GradePoint-bcqivkdwawhfzphbxypksxkvsblz/Build/Products/Debug-iphonesimulator/RealmSwift/RealmSwift.framework/Modules/RealmSwift.swiftmodule/x86_64.swiftmodule
4.  While deserializing 'SyncPermissionResults' (TypeAliasDecl #​529) in 'RealmSwift'
5.  While deserializing 'RLMSyncPermissionResults' (ClassDecl #​531) in 'RealmSwift'
6.  Cross-reference to module 'Realm'
    ... RLMSyncPermissionResults
7.  /Users/luis/Library/Developer/Xcode/DerivedData/GradePoint-bcqivkdwawhfzphbxypksxkvsblz/Build/Products/Debug-iphonesimulator/Realm/Realm.framework/Headers/RLMSyncPermissionResults.h:49:12: importing 'RLMSyncPermissionResults'
8.  While type-checking 'deinit' in module 'Realm'
9.  While loading conformances for extension of RLMSyncPermissionResults in module 'RealmSwift'
10. While reading conformance for type 'RLMSyncPermissionResults'
11. While ... to 'BidirectionalCollection' in module 'Swift'
12. While reading conformance for type 'RLMSyncPermissionResults'
13. While ... to 'Collection' in module 'Swift'
14. While reading conformance for type 'RLMSyncPermissionResults'
15. While ... to 'Sequence' in module 'Swift'
16. While deserializing 'Iterator' (TypeAliasDecl #​536) in 'RealmSwift'

A full project can be found here using the ios11 branch while running on Xcode 9 Beta 1 - 2. Just writing basic code causes issues on my setup, and im guessing it will happen for anyone else too.

belkadan commented 7 years ago

As a workaround, you can add "-Xfrontend -disable-typo-correction" to your "Other Swift Flags" build setting for now.

swift-ci commented 7 years ago

Comment by Luis Padron (JIRA)

@belkadan This has definitely helped with the segfaults, however syntax highlighting and auto completion is basically broken. As soon as I begin typing they get removed. Not sure what could be causing that issue.

belkadan commented 7 years ago

Hm, maybe SourceKit isn't picking up the Other Swift Flags.

belkadan commented 7 years ago

Fixed in https://github.com/apple/swift/pull/10715.

4.0 PR: https://github.com/apple/swift/pull/10765

swift-ci commented 7 years ago

Comment by Luis Padron (JIRA)

@belkadan Thanks for fixing this! Is there anyway to test this currently with Xcode 9 beta 2? Or will this be released in a new beta?

belkadan commented 7 years ago

You can grab a "development snapshot" from https://swift.org/download/#swift-40-development, as long as it was built after the day the fix went in.