Uploaded image for project: 'Swift'
  1. Swift
  2. SR-11564

Swift 5.1.1 Regression: Bad access on generic types exported symbols – device only.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler
    • Environment:

      DEVICE AND DEVICE SIM ONLY

      iOS 13.2 beta 2 and Xcode 11.2 beta 2. macOS Catalina (19A583)

      Description

      Hi,

      I'm running iOS 13.2 beta 2 and Xcode 11.2 beta 2.

      It appears that – when running on device or device simulator – some generic types module symbols aren't being exported.

      For example: When testing the following class as part of a SPM project:

      public class SomeThing<T> {
          
          private var thing: T?
          
          public init() {}
          
          public func doThing() {
              print("the thing")
          }
      }
      

      With the following test:

      import XCTest
      import SPMTestCrash
      
      final class SPMTestCrashTests: XCTestCase {
          func testExample() {
              let someThing = SomeThing<Int>()
              someThing.doThing() // <-- crashes here
          }
      
          static var allTests = [
              ("testExample", testExample),
          ]
      }
      

      I'm getting a bad access error.

      Although I've used an SPM project as an example, I believe it's occurring with any module export. (I'm seeing other similar bad access crashes in other code.)

      In fact, you can see with the example above (and SPM project attached) that I'm not using the `@testable` attribute to import the module for the test – I've just made the relevant API in the test class public. (Though, it also crashes with the default access modifiers and using the `@testable` attribute.)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              tcldr tcldr
              Votes:
              47 Vote for this issue
              Watchers:
              67 Start watching this issue

                Dates

                Created:
                Updated: