Skip to content

[SR-11336] Array + key-path crasher due to -enable-ownership-stripping-after-serialization for swiftCore #53737

@swift-ci

Description

@swift-ci
Previous ID SR-11336
Radar None
Original Reporter pschuh (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Crash
Assignee None
Priority Medium

md5: 6c4c6e52724c440ca710405a852fb670

blocks:

  • TF-799 Re-enable tests involving -enable-ownership-stripping-after-serialization

Issue Description:

protocol SomeProtocol {}
func SR_11336(_ array: Array<Int>) {
  let keyPaths: [PartialKeyPath<Array>] = array.indices.map { \Array<Int>[$0] }
  for kp in keyPaths {
    _ = array[keyPath: kp] is SomeProtocol
  }
}
let array: [Int] = [1000, 1]
// Crashes only if `array` contains 2 or more elements.
SR_11336(array)

The cause is enabling -Xfrontend -enable-ownership-stripping-after-serialization for swiftCore.

This was done in 4ecab47 (for swiftCore), then later in 447f008 (for swiftCore and overlays).

Reproduce:

$ swift sr-11336.swift
[1]    96610 illegal hardware instruction  $SWIFT_BIN/swift sr-11336-2.swift

Weirdly, swiftc sr-11336.swift && ./sr-11336 doesn't crash.

$ swiftc sr-11336.swift && ./sr-11336
# Succeeds, no crash.

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 softwarerun-time crashBug → crash: Swift code crashed during execution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions