Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ASan report about alloc/dealloc mismatch when compiled with C++23 #633

Merged
merged 8 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crt/aws-lc
4 changes: 4 additions & 0 deletions include/aws/crt/StlAllocator.h
Copy link
Contributor

Choose a reason for hiding this comment

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

If std::allocator<T> doesn't have any virtual functions ... does that mean nothing should inherit from it?

Copy link
Contributor Author

@waahm7 waahm7 Jun 24, 2024

Choose a reason for hiding this comment

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

Discussed offline, we will backlog this for now. We should probably be using https://docs.ros.org/en/foxy/Tutorials/Advanced/Allocator-Template-Tutorial.html

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ namespace Aws
return static_cast<RawPointer>(aws_mem_acquire(m_allocator, n * sizeof(T)));
}

#if _LIBCPP_STD_VER > 20
Copy link
Contributor

Choose a reason for hiding this comment

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

do we really need #if here?
does it really matter if we expose it in all versions of cpp standard?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

std::allocation_result was added in _LIBCPP_STD_VER > 20

std::allocation_result<T *> allocate_at_least(size_type n) { return {allocate(n), n}; }
#endif

void deallocate(RawPointer p, size_type)
{
AWS_ASSERT(m_allocator);
Expand Down
1 change: 1 addition & 0 deletions source/io/HostResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ namespace Aws

size_t len = hostAddresses ? aws_array_list_length(hostAddresses) : 0;
Vector<HostAddress> addresses;
addresses.reserve(len);

for (size_t i = 0; i < len; ++i)
{
Expand Down
Loading