Skip to content

Conversation

@mweisgut
Copy link
Contributor

@mweisgut mweisgut commented Jan 27, 2025

The deconstructor tries to deallocate memory for a given nulltpr if the move constructor has been used before. If the allocator is an std::pmr::polymorphic_allocator, the memory resource's deallocate function will be called with a nullptr. This is undefined behavior.

This PR adds a simple check so that the deconstructor only deallocates m_mem if it is not nullptr.

@gmarcais
Copy link
Owner

The difference between deallocate and delete regarding nullptr is surprising. Anyway, you are correct. Thank you for the patch and PR.

@gmarcais gmarcais changed the base branch from master to develop January 27, 2025 15:24
@gmarcais gmarcais merged commit eb83803 into gmarcais:develop Jan 27, 2025
12 checks passed
mweisgut added a commit to hyrise/hyrise that referenced this pull request May 3, 2025
This PR
- replaces `boost::container::pmr` classes with `std::pmr` as both Clang
and GCC support it.
- pushes the minimum supported GCC version from 11 to 13.2 as GCC
supports `std::pmr` in version >= 13.2.
- Updates `compact_vector` to v0.1.3 as it [tried to deallocate
memory](https://github.com/gmarcais/compact_vector/blob/9d5b66a4564582911780a9485765f61c74b95a4c/include/compact_vector.hpp#L98)
for a given [nulltpr after using the move
constructor](https://github.com/gmarcais/compact_vector/blob/9d5b66a4564582911780a9485765f61c74b95a4c/include/compact_vector.hpp#L74).
This is [undefined behavior when called on a memory
resource](https://en.cppreference.com/w/cpp/memory/memory_resource/deallocate).

Related to gmarcais/compact_vector#13

---------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants