Skip to content

[stable] Fix some File-related issues surfacing with -lowmem#9771

Merged
dlang-bot merged 4 commits intodlang:stablefrom
kinke:fixFile
May 11, 2019
Merged

[stable] Fix some File-related issues surfacing with -lowmem#9771
dlang-bot merged 4 commits intodlang:stablefrom
kinke:fixFile

Conversation

@kinke
Copy link
Contributor

@kinke kinke commented May 11, 2019

[See the commit messages.]

kinke added 4 commits May 11, 2019 21:06
As the dtor uses `mem.xfree()` to free the buffer, but read() has used
malloc/realloc/free so far. This was only an issue with an enabled GC.
I guess that wasn't a real issue before -lowmem, as most File instances
were living on the heap and NOT finalized at shutdown without enabled
GC. Anyway, a File cannot mem.xfree() a backend buffer allocated with C
malloc; fix it by NOT transferring the buffer ownership to the File and
freeing the buffer immediately after writing the object file.
When writing it to file, the File took buffer ownership and freed the
data immediately after writing it. Finalization of
`*global.params.moduleDeps` with an enabled GC would have tried to free
it again, as its buffer was still dangling.
@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @kinke! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the annotated coverage diff directly on GitHub with CodeCov's browser extension
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "stable + dmd#9771"

@dlang-bot dlang-bot merged commit 485ca68 into dlang:stable May 11, 2019
@kinke kinke deleted the fixFile branch May 11, 2019 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants