Skip to content

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

@vstakhov

Description

@vstakhov

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions