Skip to content

[SR-10264] EXC_BAD_ACCESS when assigning to a field in a testable class with a key-path #52664

@swift-ci

Description

@swift-ci
Previous ID SR-10264
Radar rdar://problem/50255258
Original Reporter Pakaste (JIRA User)
Type Bug
Environment
  • Xcode 10.2 (10E125)

  • Apple Swift version 5.0 (swiftlang-1001.0.69.5 clang-1001.0.46.3)

  • macOS 10.14.4 (18E226)

  • iOS simulator with iOS 12.2 (16E226)

Additional Detail from JIRA
Votes 2
Component/s Compiler
Labels Bug, 5.0Regression, KeyPaths, RunTimeCrash
Assignee Pakaste (JIRA)
Priority Medium

md5: fcc8044a8caab7fcf236a31574835eff

is duplicated by:

  • SR-10306 Runtime Error while using key paths with internal attributes exposed via @testable import

Issue Description:

I have the following in an iOS framework target called KeyPathCrash:

class Foo {
    var title: String = ""
}

And the following file in the test target:

import XCTest
@testable import KeyPathCrash


class KeyPathCrashTests: XCTestCase {
    func test() {
        let f = Foo()
        f[keyPath: \.title] = "bar"
    }
}

The test crashes with "Thread 1: EXC_BAD_ACCESS (code=1, address=0xfffffffffffffff8)". If I have the key-path assignment inside the framework target, it works fine.

This is a new problem with Xcode 10.2/Swift 5. It worked with Xcode 10.1/Swift 4.2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwarekey pathsFeature: key paths (both native and Objective-C)regressionrun-time crashBug → crash: Swift code crashed during executionswift 5.0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions