Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

core.stdcpp.allocator: _Adjust_manually_vector_aligned checks for sentinel unconditionally (Windows only) #3265

Merged
merged 1 commit into from
Mar 18, 2021

Conversation

n8sh
Copy link
Member

@n8sh n8sh commented Nov 9, 2020

This bug resulted in assertion failures when deleting large blocks of memory using core.stdcpp.allocator on Windows. _Allocate_manually_vector_aligned only sets a sentinel when version(_DEBUG) so _Adjust_manually_vector_aligned should only check for this sentinel when version(_DEBUG).

Additionally change the linkage of those functions from C++ to D to avoid possible linker confusion.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @n8sh!

Bugzilla references

Auto-close Bugzilla Severity Description
21371 normal core.stdcpp.allocator: _Adjust_manually_vector_aligned checks for sentinel unconditionally (Windows only)

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 "stable + druntime#3265"

@dlang-bot dlang-bot added the Bug Fix Include reference to corresponding bugzilla issue label Nov 9, 2020
Copy link
Contributor

@TurkeyMan TurkeyMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for isolating this!

@thewilsonator
Copy link
Contributor

Hmm, the test seems to hang on windows

@n8sh
Copy link
Member Author

n8sh commented Nov 21, 2020

Hmm, the test seems to hang on windows

My guess is that this is because the test is actually failing on Windows and an "abort or debug?" prompt is appearing. IIRC that happened recently on another PR. My guess for why a failure would be is happening is a difference in that, unlike xutility.d, allocator.d does not infer where to use _DEBUG behavior based on mscrtlib . I'll see if changing it fixes this.

@thewilsonator
Copy link
Contributor

nope.

…ned checks for sentinel unconditionally (Windows only)

This bug resulted in assertion failures when deleting large blocks of memory using core.stdcpp.allocator on Windows. _Allocate_manually_vector_aligned
only sets a sentinel when version(_DEBUG) so _Adjust_manually_vector_aligned
should only check for this sentinel when version(_DEBUG).

Additionally change the linkage of those functions from C++ to D to avoid
possible linker confusion.

Also changed the logic by which allocator.d infers _DEBUG to resemble the
the logic for _ITERATOR_DEBUG_LEVEL in utility.d.
@n8sh
Copy link
Member Author

n8sh commented Mar 18, 2021

Should be working now.

@dlang-bot dlang-bot merged commit 74287fb into dlang:stable Mar 18, 2021
else
{
import core.stdcpp.xutility : __CXXLIB__;
enum _DEBUG = __CXXLIB__.length && 'd' == __CXXLIB__[$-1]; // libcmtd, msvcrtd
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this is good. If the logic that drives the codegen doesn't match C++, then you'll get weird link errors that are hard for a user to diagnose.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Fix Include reference to corresponding bugzilla issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants