Swift's stdlib Array.removeAtIndex/Array.append crash after a few (39) iterations inserting / removing elements

Originator:info
Number:rdar://22873620 Date Originated:27-Sep-2015 03:11 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 7.1 / Swift 2.1
Classification:Crash/Hang/Data Loss Reproducible:Always
 
Summary:
The attached project shows how a fairly common use of Array, inserting and removing objects, results in very consistent crashes.
I managed to create a simple test that reproduces this issue (SignalSpec.swift:18). 

Example crash showing the stack trace: https://cloud.githubusercontent.com/assets/685609/10120983/a4a2fa1e-648b-11e5-9885-50e1fcb8060f.png

Steps to Reproduce:
- Unzip attached project.
- Open ReactiveCocoa.xcworkspace.
- Select ReactiveCocoa iOS scheme.
- Run tests (⌘ + U) (this will only run the failing tests because it’s marked with `fcontext`)

Expected Results:
Tests passes (as it does in Xcode 7.0).

Actual Results:
After only 39 iterations the process crashes with
malloc: *** mach_vm_map(size=70918499991552) failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug

Regression:
This does not reproduce in Xcode 7 (Swift 2.0). You can use the same project to confirm this (no need to update the code at all)

Notes:
We’re tracking this issue here: https://github.com/ReactiveCocoa/ReactiveCocoa/issues/2417

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!