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

MemoryBufferTest.MoveCtor provokes undefined sanitizer #1344

Closed
orivej opened this issue Oct 6, 2019 · 1 comment · Fixed by #1349
Closed

MemoryBufferTest.MoveCtor provokes undefined sanitizer #1344

orivej opened this issue Oct 6, 2019 · 1 comment · Fixed by #1349

Comments

@orivej
Copy link
Contributor

orivej commented Oct 6, 2019

When MoveCtor performs check_move_buffer, the buffer allocator becomes null as expected, but then MoveCtor attempts to use it to allocate a dynamic buffer. UBSAN reports this as a reference binding to a null pointer at TestAllocator.allocate. I think that this succeeds nevertheless because a typical std::allocator<char>::allocate does not use this, so it does not crash when this is null.

@vitaut
Copy link
Contributor

vitaut commented Oct 6, 2019

Good catch. The test should really create a new buffer before doing the dynamic allocation part.

orivej added a commit to orivej/fmt that referenced this issue Oct 8, 2019
When `MoveCtor` performs `check_move_buffer`, the buffer allocator becomes null,
but then `MoveCtor` attempts to use it to allocate a dynamic buffer. This
succeeds nevertheless because a typical `std::allocator<char>::allocate` does
not use `this`, so it does not crash when `this` is null.

Fixes fmtlib#1344
orivej added a commit to orivej/fmt that referenced this issue Oct 8, 2019
When `MoveCtor` performs `check_move_buffer`, the buffer allocator becomes null,
but then `MoveCtor` attempts to use it to allocate a dynamic buffer. This
succeeds nevertheless because a typical `std::allocator<char>::allocate` does
not use `this`, so it does not crash when `this` is null.

Fixes fmtlib#1344
vitaut pushed a commit that referenced this issue Oct 8, 2019
When `MoveCtor` performs `check_move_buffer`, the buffer allocator becomes null,
but then `MoveCtor` attempts to use it to allocate a dynamic buffer. This
succeeds nevertheless because a typical `std::allocator<char>::allocate` does
not use `this`, so it does not crash when `this` is null.

Fixes #1344
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 a pull request may close this issue.

2 participants