Swift: Crash when using "ExtAudioFileRef"
| Originator: | charlesism.com | ||
| Number: | rdar://17211521 | Date Originated: | 06-Jun-2014 |
| Status: | Open | Resolved: | |
| Product: | Swift | Product Version: | |
| Classification: | Reproducible: | Always |
Summary:
Attempting to create an "ExtAudioFileOpenURL" from Swift causes the program to subsequently crash with a memory-related error.
Steps to Reproduce:
================================================
import AVFoundation
let path = NSBundle.mainBundle().pathForSoundResource( "Glass.aiff" )
let audio_path = NSURL.fileURLWithPath( path )
var unmanaged_audio_file: Unmanaged<ExtAudioFile>?
var err = ExtAudioFileOpenURL( audio_path, &unmanaged_audio_file )
var audio_file: ExtAudioFile = unmanaged_audio_file!.takeRetainedValue()
println( "ExtAudioFileOpenURL error code: \(err)" )
ExtAudioFileDispose( audio_file )
================================================
Expected Results:
I expect to see the output "ExtAudioFileOpenURL error code: 0"
Actual Results:
While I do see the output "ExtAudioFileOpenURL error code: 0", the program subsequently crashes: with the message: " EXC_BAD_ACCESS(code=1, address=0x...)"
Version:
System Version: OS X 10.9.3 (13D65)
Kernel Version: Darwin 13.2.0
Notes:
One of your engineers replied to my post in the Forums:
https://devforums.apple.com/message/977528#977528
"This is a bug in the Swift SDK. Swift thinks ExtAudioFileRef is a CoreFoundation-style object that can retained and released, but that is not true. Please file a bug report so we can fix that.
I can't think of any workaround that will convince Swift not to try to retain and release your ExtAudioFileRef objects."
Configuration:
Xcode Version 6.0 (6A215l)
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!