This repository was archived by the owner on Dec 29, 2022. It is now read-only.
Repository navigation
[linux-port] fix refcounting on imalloc and others - #200
Merged
Merged
Conversation
|
✅ Build DirectXShaderCompiler 1.0.64 completed (commit f5e484e77c by @pow2clk) |
pow2clk
commented
May 21, 2018
Author
There was a problem hiding this comment.
Oops. I'll fix this in a future version.
pow2clk
commented
May 21, 2018
|
Are you changing the SPIR-V Tools version? |
Author
|
not intentionally. I'll fix it with the other mistakes. Is there anything else I should change? |
The previous macro for InterlockedIncrement and InterlockedDecrement didn't affect the parameter, rather it only returned the correct result. This caused some subtle memory leaks, that, when fixed, caused segfaults because an IMalloc structure was being used after it had been freed because a refcount increment was missing during CoGetMalloc, which allocates a brand new malloc and assigns it to the given parameter, which creates a new reference. Specifically, in the run I was debugging, DxcCreateBlobFromFile created a null CComPtr, which it almost immediately assigned IMalloc to, but since CoGetMalloc didn't increment the refcount, when the function ended, the CComPtrBase destructor decremented the count on the IMalloc without a corresponding increment when it was associated with the CComPtr. So it got freed just a bit early, causing a segfault. Prerequisite for google#198 Though it's not directly related, but the change for that would introduce the segfault otherwise and I prefer to discuss these changes independently.
ehsannas
approved these changes
May 22, 2018
ehsannas
left a comment
There was a problem hiding this comment.
LGTM. One of Travis jobs has reached the time limit.
Author
|
sigh 😞 Can you restart it for me? Or shall I resubmit? |
|
✅ Build DirectXShaderCompiler 1.0.66 completed (commit 53b715983b by @pow2clk) |
|
No need. LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The previous macro for InterlockedIncrement and InterlockedDecrement
didn't affect the parameter, rather it only returned the correct
result. This caused some subtle memory leaks, that, when fixed,
caused segfaults because an IMalloc structure was being used after
it had been freed because a refcount increment was missing during
CoGetMalloc, which allocates a brand new malloc and assigns it to
the given parameter, which creates a new reference.
Specifically, in the run I was debugging, DxcCreateBlobFromFile
created a null CComPtr, which it almost immediately assigned IMalloc
to, but since CoGetMalloc didn't increment the refcount, when the
function ended, the CComPtrBase destructor decremented the count
on the IMalloc without a corresponding increment when it was associated
with the CComPtr. So it got freed just a bit early, causing a segfault.
Prerequisite for #198
Though it's not directly related, but the change for that would
introduce the segfault otherwise and I prefer to discuss these
changes independently.