New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-6536] Creating a string description of a Swift.Error with an associated optional Swift.Error leaks a _SwiftNativeNSError (80 bytes) #49086
Comments
@swift-ci create |
It looks like `A.a` has to have an `Optional` payload to trigger the leak. Making `B` CustomDebugStringConvertible seems to work around the leak. |
It also looks like `B` has to specifically be an enum, as opposed to a struct. Slightly reduced repro case: import Foundation
public enum B: Error { case b }
autoreleasepool {
print(B.b as Error?)
} |
Leak appears to be independent of the `Error` protocol as well. This also reproduces the leak for me: import Foundation
protocol P {}
public enum B: P { case b }
autoreleasepool {
print(B.b as P?)
} |
Leak seems to be caused somewhere during mirror traversal. This also leaks, using `dump` instead of `print`: import Foundation
protocol P {}
public enum B: P {
case b
}
autoreleasepool {
dump(B.b as P)
} |
Comment by James Froggatt (JIRA) I'm getting something like this bug as well, without Optional: public enum ANTLRException: Error {
case parseCancellation(e: RecognitionException)
case recognition(e: RecognitionException)
} Here, `RecognitionException` doesn't conform to `Error`. Attempting to catch the `ANTLRException` error (from another module) gives a `_SwiftNativeNSError`, and attempts to cast to `ANTLRException` fail. Attempts to print or get the localizedDescription also result in a crash. |
SAJim (JIRA User) Can you file a new bug for that? Looking at the presence of |
Comment by James Froggatt (JIRA) Thanks Joe, it did turn out to be a completely different problem. I'll file a report when I have a moment. |
@slavapestov fixed a runtime leak in #13792 that's probably responsible for this. |
Additional Detail from JIRA
md5: 516259d527c380fec26379fe9db0bea3
Issue Description:
Executing the following code will always leak an instance of _SwiftNativeNSError (80 bytes).
Steps to reproduce:
Execute the code above.
Use the Memory Graph Debugger to create a snapshot
Check the runtime issues tab in Xcode.
Verified in Xcode 9.1 and Xcode 9.2
The text was updated successfully, but these errors were encountered: