apple / apple/swift-algorithms
Adding a CompactedCollection to an Array triggers EXC_BAD_ACCESS
- Dominant language
- Swift
- Stars
- 6.3k
- Forks
- 483
- PR merge metrics
- No merged PRs in 30d
Description
When combining a CompactedCollection of objects with an array of objects, in release mode, code will crash with EXC_BAD_ACCESS.
**Swift Algorithms version:**
`1.1.0` but I also saw this in `0.0.3`
**Swift version:**
swift-driver version: 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
Target: arm64-apple-macosx14.0
### Checklist
- [x] If possible, I've reproduced the issue using the `main` branch of this package
- [x] I've searched for [existing GitHub issues](https://github.com/apple/swift-algorithms/issues)
### Steps to Reproduce
I've attached an iOS project that reproduces this. From the Xcode template, I've edited the scheme to run in Release mode. Here is the relevant code that triggers the crash:
```swift
final class Thing {}
let things = [Thing()].compacted() + [Thing()]
print("things", things)
```
### Expected behavior
Not to crash
### Actual behavior
EXC_BAD_ACCESS
Contributor guide
Research direction
Start with the provided reproduction, especially the `CompactedCollection` expression combining `[Thing()].compacted()` with `[Thing()]`, and run it in Release mode on the stated Swift and macOS target. Trace the collection combination and add a regression test for this case; done means the Release build no longer reports `EXC_BAD_ACCESS` and the expected collection can be printed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100