Modifying a XCSourceTextBuffer's completeBuffer crashes Xcode

Originator:SaagarJha28
Number:rdar://27980447 Date Originated:23-Aug-2016 05:56 PM
Status:Closed Resolved:29-Jan-2017 10:17 AM
Product:Developer Tools Product Version:Xcode Version 8.0 beta 6 (8S201h)/macOS Sierra 10.12 Beta (16A304a)
Classification:Crash/Hang/Data Loss Reproducible:
 
Summary:
Changing a XCSourceTextBuffer's completeBuffer property in perform(with:completionHandler:) (for example, to replace all its text with a formatted version) will crash Xcode. Attached is a crash log and a sample project.

Steps to Reproduce:
1. Create an Xcode project and add an Xcode Source Editor Extension.
2. In SourceEditorCommand.swift's perform(with:completionHandler:), set invocation.buffer.completeBuffer.
3. Run the source editor command.

Expected Results:
The buffer is changed.

Actual Results:
Crash.

Version:
Xcode Version 8.0 beta 6 (8S201h)/macOS Sierra 10.12 Beta (16A304a)

Notes:


Configuration:
Late 2011 MacBook Pro running macOS Sierra 10.12 Beta (16A304a)

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!