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

[BUG] Using delete operator for the memory allocated with placement new #42

Closed
vstakhov opened this issue Jul 19, 2022 · 2 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@vstakhov
Copy link

Describe the bug
The code uses delete operator for the object created via placement new operator. This is non-conformant and should be probably replaced via storage->~storage() followed by ::operator delete(mem); for the ptr itself.

It also invokes asan crash:

0x6060002b5560 in thread T0:
  object passed to delete has wrong type:
  size of the allocated type:   56 bytes;
  size of the deallocated type: 16 bytes.
    #0 0x49eba7 in operator delete(void*, unsigned long) (/usr/bin/rspamd+0x49eba7)
    #1 0x7f323b89e558 in ankerl::v1_0_0::svector<unsigned int, 4ul>::realloc(unsigned long) (/usr/lib64/rspamd/librspamd-server.so+0x4c7558)

0x6060002b5560 is located 0 bytes inside of 56-byte region [0x6060002b5560,0x6060002b5598)
allocated by thread T0 here:
    #0 0x49db47 in operator new(unsigned long) (/usr/bin/rspamd+0x49db47)
    #1 0x7f323b89e1ce in ankerl::v1_0_0::svector<unsigned int, 4ul>::realloc(unsigned long) (/usr/lib64/rspamd/librspamd-server.so+0x4c71ce)

To Reproduce
Steps to reproduce the behavior:

  1. Build any test with gcc asan

Expected behavior

No crash.

System (please complete the following information):

  • OS: Centos 7
  • Compiler: gcc 8
  • Version: master branch
@vstakhov vstakhov added the bug Something isn't working label Jul 19, 2022
martinus added a commit that referenced this issue Jul 19, 2022
copied from unordered_dense

added gcc's asan. Who knew, it finds stuff that clang++ did not find.
@martinus
Copy link
Owner

Thanks for the report! I've now added gcc asan build to my build script and fixed this issue. I'll create a new release for that.

PS: Also thanks for your generous contribution 🙂

@vstakhov
Copy link
Author

Thank you for a quick fix! I really like your libraries: they fix the long-standing std c++ issues without boost style code bloating and compatibility issues.

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