-
Notifications
You must be signed in to change notification settings - Fork 1.2k
SR-6449: FileManager.removeItem(atPath) leaks #1397
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
Conversation
- FileManager.fileSystemRepresentation returns a heap allocated pointer that needs to be freed by the caller.
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem like the right fix. It would require all clients to insert a deallocate call.
I think we may need to instead introduce a new API here that gives you the representation in a closure, somewhat like withUnsafeBytes. Plus mark this one as unavailable on Linux. These APIs that rely on an autorelease pool are problematic for us. |
@parkera I agree that replacing it with a better API is preferable (as we should with all of the methods that return an autoreleased result). Can we not just return a |
@parkera Is it worth just fixing this in the 4.1 branch to remove the leak but then coming up with something better for 5 onwards? |
I think we're stuck with this until Swift 5, since we shouldn't introduce a source breaking change in a dot release. The Swift 5 solution probably has to be a replacement method. |
FileManager could perhaps switch to some other mechanism of getting the C string. |
@parkera Sorry, when I said fixing it in 4.1 I meant applying this PR to 4.1-branch to just fix the leak, not change the API. |
I thought about this some and I guess this makes sense to do in the short term. Eventually we'll have to just deprecate this API (or remove it, maybe). |
@swift-ci please test and merge |
pointer that needs to be freed by the caller.