Debugger holds strong reference to results of expressions when used with Swift

Originator:david.ronnqvist
Number:rdar://28633569 Date Originated:05-Oct-2016
Status:Duplicate of 23342985 (Open) Resolved:
Product:Developer Tools Product Version:Xcode 8.0 (8A218a)
Classification:Serious Bug Reproducible:Always
 
Summary:
When using Swift, the debugger holds on to any variable that's printed to the debugger. 

Put simply, if I hit a breakpoint and do "po self", that object will never be released (see attached DebuggerRetainsObject.xcodeproj). There are many variations of this (see Additional Information below)

The same scenario in Objective-C works as expected (see attached WorksFineInObjC.xcodeproj).

Steps to Reproduce:
1. Open the attached sample project (DebuggerRetainsObject)
2. Put a break point in the initializer of SomeClass (line 23 in AppDelegate.swift)
3. Build and run the application
4. When the breakpoint is hit: type "po self" in the console
5. Press continue

Expected Results:
The instance of SomeClass is released and both "init" and "deinit" are printed to the console

Actual Results:
The instance is never released, and only "init" is ever printed to the console.

Version:
Xcode 8.0 (8A218a)

Notes:
The issue doesn't appear to be with referencing self in the debugger, but with having self be the result of an expression. 

For example:
 - "po self == nil" will output "false" without holding on to the instance of SomeClass.
 - "po self.someProperty" will output "some value" without holding on to the instance of SomeClass
 - "po "\(self)"" will output "<SomeClass: 0x600000043ae0>" without holding on to the instance of SomeClass

Also, editing the break point to log  "@self@" will hold on to the instance preventing it from being released. 

However, choosing "Print description of "self" " in the context menu from the Variables View in the Debug Area outputs "Printing description of self:
<SomeClass: 0x600000043ae0>" without holding on to the instance.

Configuration:


Attachments:
'DebuggerRetainsObject.zip' and 'WorksFineInObjC.zip' were successfully uploaded.

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!