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

Using non scalar element type for the buffer leads to crash #84

Open
Alex-PLACET opened this issue Apr 29, 2024 · 2 comments
Open

Using non scalar element type for the buffer leads to crash #84

Alex-PLACET opened this issue Apr 29, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Alex-PLACET
Copy link
Collaborator

Using non scalar element type like std::string, leads to a crash in the deallocation code.

@JohanMabille
Copy link
Collaborator

JohanMabille commented Apr 30, 2024

After some investigations, it crashes if the initial string buffer is allocated with operator new[] instead of using the standard allocator:

{
    std::size_t size = 8u;
    std::string* raw_buf = new std::string[size];
    buffer<std::string> buf(raw_buf, size);
    // Wil crash when getting out of scope
}

Replacing the allocation with buffer<std::string>::allocator_type alloc; alloc.allocate(size); fixes the issue.

@JohanMabille
Copy link
Collaborator

Under Linux with gcc, the reason is that internally, std::allocator<T>::allocate calls _GLIBCXX_OPERATOR_NEW , which might be different from operator new

@Alex-PLACET Alex-PLACET added the bug Something isn't working label Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants