[BUG] undefined behavior in pmr container destructor
justusranvier opened this issue · comments
I've been tracking down some UBSan warnings in my project and it seems to originate from ankerl::unordered_dense::v2_0_2::detail::table::~table().
Every time that destructor runs for an ankerl::unordered_dense::pmr::map or ankerl::unordered_dense::pmr::set I get the following UBsan output:
/usr/lib/gcc/powerpc64le-unknown-linux-gnu/12/include/g++-v12/memory_resource:489:24: runtime error: null pointer passed as argument 1, which is declared to never be null
/usr/lib/gcc/powerpc64le-unknown-linux-gnu/12/include/g++-v12/memory_resource:186:22: note: nonnull attribute specified here
I don't have a minimal test case at the moment, but the ubsan errors appear to be triggered 100% of the time when an ankerl::unordered_dense::pmr container destructs, and the errors cease when those containers are replaced with their std::pmr equivalents or with non-pmr unordered_dense containers.
Hi, thanks for the report! Can you give this version a try if this fixes the issue? https://raw.githubusercontent.com/martinus/unordered_dense/2023-01-fix-deallocate-nullptr/include/ankerl/unordered_dense.h
Fixed in #56
I created release v3.0.1 which I'm pretty sure fixes the issue. Thanks for reporting!
v3.0.1 fixes the ubsan errors for me