dmd icon indicating copy to clipboard operation
dmd copied to clipboard

CTFE scrubReturnValue(): fix omission

Open WalterBright opened this issue 6 years ago • 5 comments

Skipping this case led to a dangling reference to deleted Region allocations, i.e. memory corruption. Don't have a reasonable test case for it - spent 3 days till I found it :-(

This PR is just the fix. I plan later to do a refactoring on it to make the code saner.

WalterBright avatar Oct 07 '19 10:10 WalterBright

Thanks for your pull request, @WalterBright!

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 run digger -- build "master + dmd#10458"

dlang-bot avatar Oct 07 '19 10:10 dlang-bot

Looks like I have more work to do on this, sigh.

WalterBright avatar Oct 07 '19 10:10 WalterBright

When newCTFE is in, at least these kinds of bugs are virtually impossible. Since all returned values have to go through a transform which creates a dmd expression, node from a newCTFE-Value.

UplinkCoder avatar Oct 22 '19 23:10 UplinkCoder

@WalterBright "fix omission" is not a good commit message. Especially if it's an obscure case. As soon as this is ready please do adjust the commit message to a few sentences which would explain to someone who is not familiar with the issue, what the issue was and why the solution you have for it is correct.

I personally do this all the time now for things which are bugfixes intended for merge.

UplinkCoder avatar Jan 23 '21 12:01 UplinkCoder

@WalterBright, I fixed a similar bug some time ago, a self reference got allocated in the stack but escaped to other contexts. See #13109 Maybe it's the same.

BorisCarvajal avatar Jul 16 '22 15:07 BorisCarvajal