Skip to content

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

Merged
merged 1 commit into from
Mar 24, 2018

Conversation

spevans
Copy link
Contributor

@spevans spevans commented Jan 18, 2018

  • FileManager.fileSystemRepresentation returns a heap allocated
    pointer that needs to be freed by the caller.

- FileManager.fileSystemRepresentation returns a heap allocated
  pointer that needs to be freed by the caller.
@spevans
Copy link
Contributor Author

spevans commented Jan 18, 2018

@swift-ci please test

Copy link
Contributor

@parkera parkera left a 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.

@parkera
Copy link
Contributor

parkera commented Jan 18, 2018

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.

@spevans
Copy link
Contributor Author

spevans commented Jan 19, 2018

@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 String and try and avoid any mention of Unsafe?

@spevans
Copy link
Contributor Author

spevans commented Feb 13, 2018

@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?

@parkera
Copy link
Contributor

parkera commented Feb 15, 2018

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.

@parkera
Copy link
Contributor

parkera commented Feb 15, 2018

FileManager could perhaps switch to some other mechanism of getting the C string.

@spevans
Copy link
Contributor Author

spevans commented Feb 15, 2018

@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.

@parkera
Copy link
Contributor

parkera commented Feb 15, 2018

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).

@spevans
Copy link
Contributor Author

spevans commented Mar 23, 2018

@swift-ci please test and merge

2 similar comments
@spevans
Copy link
Contributor Author

spevans commented Mar 23, 2018

@swift-ci please test and merge

@spevans
Copy link
Contributor Author

spevans commented Mar 23, 2018

@swift-ci please test and merge

@swift-ci swift-ci merged commit 6fb308c into swiftlang:master Mar 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants