# New "segmentation fault 11" in Swift 5.6

**URL:** <https://forums.swift.org/t/new-segmentation-fault-11-in-swift-5-6/56141>\
**Category:** Pitches\
**Tags:** bug, compiler, segmentation-fault\
**Created:** [March 22, 2022, 5:32pm UTC](https://forums.swift.org/t/new-segmentation-fault-11-in-swift-5-6/56141 "2022-03-22T17:32:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeremyabannister](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jeremyabannister/32/10143_2.png) [@jeremyabannister](https://forums.swift.org/u/jeremyabannister)\
**Post date:** [March 22, 2022, 5:32pm UTC](https://forums.swift.org/t/new-segmentation-fault-11-in-swift-5-6/56141/1 "2022-03-22T17:32:19Z")

</div>

This code used to compile and function correctly (prior to Swift 5.6) but now with Swift 5.6 I get a "segmentation fault 11" error:

```swift
///
import SwiftUI

///
public protocol DisplayableValue {
    
}

///
public protocol SingleValueDisplay: View {
    
    ///
    associatedtype DisplayedValue
    
    ///
    init (_ singleValue: DisplayedValue)
    
    ///
    var displayedValue: DisplayedValue { get }
}

///
public protocol RawDisplayableValue: DisplayableValue {
    
    ///
    associatedtype RawDisplay: SingleValueDisplay
        where RawDisplay.DisplayedValue == Self
}

///
public protocol RawTextDisplayableValue: RawDisplayableValue
    where Self: CustomStringConvertible,
          RawDisplay == RawTextDisplay<Self> { }

///
public struct RawTextDisplay <Value: CustomStringConvertible>: SingleValueDisplay {
    
    ///
    public var displayedValue: Value
    
    ///
    public init (_ singleValue: Value) {
        self.displayedValue = singleValue
    }
    
    ///
    public var body: some View {
        Text(displayedValue.description)
    }
}

```

What's the proper way to file this as a bug?

---

<div class="post-metadata">

**Author:** ![Slava\_Pestov](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/slava_pestov/32/30204_2.png) [@Slava\_Pestov](https://forums.swift.org/u/Slava_Pestov)\
**Post date:** [March 22, 2022, 5:38pm UTC](https://forums.swift.org/t/new-segmentation-fault-11-in-swift-5-6/56141/2 "2022-03-22T17:38:55Z")

</div>

Thanks for the bug report. This hits a known issue in 5.6. You can work around it by building with the "-Xfrontend -requirement-machine=off" compiler flag (in Xcode, this is the OTHER\_SWIFT\_FLAGS build setting).

On main this appears to hit a different problem, so I'll take a look.

---

<div class="post-metadata">

**Author:** ![jeremyabannister](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jeremyabannister/32/10143_2.png) [@jeremyabannister](https://forums.swift.org/u/jeremyabannister)\
**Post date:** [March 22, 2022, 5:48pm UTC](https://forums.swift.org/t/new-segmentation-fault-11-in-swift-5-6/56141/3 "2022-03-22T17:48:58Z")

</div>

Thanks Slava! Is this possible to do if this code lives in a Swift package?

* * *

I know I can do this in any apps which import the package, but it would be nice to be able to build the package on its own from Xcode.

---

<div class="post-metadata">

**Author:** ![Slava\_Pestov](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/slava_pestov/32/30204_2.png) [@Slava\_Pestov](https://forums.swift.org/u/Slava_Pestov)\
**Post date:** [March 22, 2022, 5:54pm UTC](https://forums.swift.org/t/new-segmentation-fault-11-in-swift-5-6/56141/4 "2022-03-22T17:54:55Z")

</div>

Unfortunately any app that uses the RawTextDisplayableValue protocol will need the same flag.

The only other workaround I can suggest is to change the return type of 'var body' in RawTextDisplay from 'some View' to 'AnyView', but that might not be appropriate.

---

<div class="post-metadata">

**Author:** ![jeremyabannister](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jeremyabannister/32/10143_2.png) [@jeremyabannister](https://forums.swift.org/u/jeremyabannister)\
**Post date:** [March 22, 2022, 5:58pm UTC](https://forums.swift.org/t/new-segmentation-fault-11-in-swift-5-6/56141/5 "2022-03-22T17:58:08Z")

</div>

Awesome, I prefer the `AnyView` workaround because the code isn't that performance sensitive, nor will changing it back to `some View` whenever that becomes possible cause problems at any of the usage sites. Thanks a lot.

---

<div class="post-metadata">

**Author:** ![Slava\_Pestov](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/slava_pestov/32/30204_2.png) [@Slava\_Pestov](https://forums.swift.org/u/Slava_Pestov)\
**Post date:** [March 22, 2022, 6:00pm UTC](https://forums.swift.org/t/new-segmentation-fault-11-in-swift-5-6/56141/6 "2022-03-22T18:00:43Z")

</div>

Do you mind filing a bug with your test case on [bugs.swift.org](http://bugs.swift.org) so I can track the fix for the second issue (which is not present on 5.6)?

---

<div class="post-metadata">

**Author:** ![jeremyabannister](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jeremyabannister/32/10143_2.png) [@jeremyabannister](https://forums.swift.org/u/jeremyabannister)\
**Post date:** [March 22, 2022, 6:06pm UTC](https://forums.swift.org/t/new-segmentation-fault-11-in-swift-5-6/56141/7 "2022-03-22T18:06:06Z")

</div>

No problem, here it is:

[https://bugs.swift.org/browse/SR-16040](https://bugs.swift.org/browse/SR-16040)

---

<div class="post-metadata">

**Author:** ![Slava\_Pestov](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/slava_pestov/32/30204_2.png) [@Slava\_Pestov](https://forums.swift.org/u/Slava_Pestov)\
**Post date:** [March 22, 2022, 7:07pm UTC](https://forums.swift.org/t/new-segmentation-fault-11-in-swift-5-6/56141/8 "2022-03-22T19:07:43Z")

</div>

Thanks, I have a fix up for the issue on main: [AST: TypeMatcher needs to recurse into OpaqueTypeArchetypeTypes by slavapestov · Pull Request #41958 · apple/swift · GitHub](https://github.com/apple/swift/pull/41958)
