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

<vector>: x86 ASAN failure with pmr::monotonic_buffer_resource #3205

Closed
Caball009 opened this issue Nov 11, 2022 · 1 comment · Fixed by #3164
Closed

<vector>: x86 ASAN failure with pmr::monotonic_buffer_resource #3205

Caball009 opened this issue Nov 11, 2022 · 1 comment · Fixed by #3164
Labels
ASan Address Sanitizer bug Something isn't working fixed Something works now, yay!

Comments

@Caball009
Copy link

Might be related to: #3164

Initializing std::vector + std::pmr::monotonic_buffer_resource causes ASAN to throw an exception in x86 mode under certain conditions.

The following code shows this, but unfortunately I was unable to add ASAN to MSVC in compiler explorer, so instead GCC x86 and x64 were added to show there's no problem there.
https://godbolt.org/z/sM931fbP3
https://godbolt.org/z/vbzEa4cba

The code from the first link for posterity's sake:

#include <array>
#include <iostream>
#include <memory_resource>
#include <vector>

int main()
{
    using T = std::pmr::vector<std::uint8_t>;

    std::array<std::uint8_t, 8192> buffer{};
    std::pmr::monotonic_buffer_resource mbr(buffer.data(), buffer.size(), 
        std::pmr::null_memory_resource());
    
    T vec1(128, &mbr);
    T vec2(128, &mbr);

    std::cout << "So far so good\n";

    T vec3(100, &mbr);
    T vec4(128, &mbr); // <-- asan throws exception here

    std::cout << "All good\n";
}

Visual Studio 2022 versions:

  • v17.4.0, various preview versions (preview 2.1, preview 6)
  • v17.5.0

Notable compiler settings / flags

  • Debug mode
  • x86 (NOT x64)
  • C++17 / C++20
  • Address sanitizer enabled (/fsanitize=address)

NB: ASAN would only thow an exception in x86 mode + Visual Studio 2022. I was unable to reproduce the issue with Visual Studio 2019, neither x86 nor x64 (I don't have a VS2019 version number at hand, but it was quite recent).

@StephanTLavavej StephanTLavavej added bug Something isn't working ASan Address Sanitizer labels Nov 11, 2022
@strega-nil-ms
Copy link
Contributor

Yep! As far as I can tell, this is fixed by #3164 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASan Address Sanitizer bug Something isn't working fixed Something works now, yay!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants