This repository was archived by the owner on Oct 12, 2022. It is now read-only.
Fix Issue 4587 - Assert exception should not allocate#1714
Closed
Darredevil wants to merge 1 commit intodlang:masterfrom
Closed
Fix Issue 4587 - Assert exception should not allocate#1714Darredevil wants to merge 1 commit intodlang:masterfrom
Darredevil wants to merge 1 commit intodlang:masterfrom
Conversation
Contributor
|
Contributor
Author
lindt
reviewed
Dec 19, 2016
| if( _assertHandler is null ) | ||
| throw new AssertError( file, line ); | ||
| import core.stdc.string : memcpy; | ||
| char[1024] buffer; |
There was a problem hiding this comment.
declare this buffer just within the if
1024 is random and a magic number, you could be concrete with char[__traits(classInstanceSize, AssertError)] buffer;
Member
There was a problem hiding this comment.
Not to mention the alignment issue - I don't think there is guarantee that char[x] array is properly aligned.
Member
There was a problem hiding this comment.
Not to also mention -- this is a local buffer which you are throwing outside the function. This results in corruption. Make it a static buffer.
| if( _assertHandler is null ) { | ||
| enum size = __traits(classInstanceSize, AssertError); | ||
| memcpy(buffer.ptr, typeid(AssertError).initializer().ptr, size); | ||
| auto obj = cast(AssertError) buffer.ptr; |
Member
There was a problem hiding this comment.
emplace is from Phobos, cannot be used.
Member
|
I think we should close this in favor of #1710 |
Member
|
Yah, let's focus on #1710 and friends. |
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.
Work in Progress
https://issues.dlang.org/show_bug.cgi?id=4587