Skip to content

[SR-4477] Protocol composition results in EXC_BAD_ACCESS #47054

@swift-ci

Description

@swift-ci
Previous ID SR-4477
Radar rdar://problem/31404278
Original Reporter salutis (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug, Runtime
Assignee salutis (JIRA)
Priority Medium

md5: c528652076c750121e14e91c0b0093b8

is duplicated by:

  • SR-5043 App crashes when calling method on downcasted object

Issue Description:

An EXC_BAD_ACCESS here:

protocol Something {}

protocol IntContainer {
    var ints: [Int] { get set }
}

func processSomething(_ state: Something) {
    if let intContainer = state as? Something & IntContainer {
        print(intContainer.ints)
    }
}

struct MySomething: Something, IntContainer {
    var ints: [Int] = []
}

let mySomething = MySomething()
processSomething(mySomething) // EXC_BAD_ACCESS here

The execution stops here:

libswiftCore.dylib`_swift_release_dealloc:
    0x11be163e0 <+0>: movq   (%rdi), %rax
->  0x11be163e3 <+3>: jmpq   *-0x10(%rax)
    0x11be163e6 <+6>: nopw   %cs:(%rax,%rax)

Related StackOverflow question with no good answer:
http://stackoverflow.com/questions/35199077/exc-bad-access-using-protocol-composition

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.runtimeThe Swift Runtimestandard libraryArea: Standard library umbrella

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions