Skip to content

ASan reports new-delete-type-mismatch in lock-free stack example #12

@powergee

Description

@powergee

Hello,

It appears that the current implementation contains undefined behavior. I ran the lock-free stack example with AddressSanitizer (ASan) enabled, and it reports a new-delete-type-mismatch error. This indicates that the size used for deallocation does not match the one used for allocation.

I reproduced this issue on an x86 Ubuntu 22.04 machine with g++ 11.4.0.

Reproduction

To build the example with ASan enabled and fix some compilation errors, please apply the following changes.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e2b4780..6f7dea2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,6 +4,13 @@ project(SGCL LANGUAGES CXX)
 set(CMAKE_CXX_STANDARD 20)
 set(CMAKE_CXX_STANDARD_REQUIRED ON)
 
+option(ENABLE_ASAN "Enable AddressSanitizer" OFF)
+if(ENABLE_ASAN)
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -g -fno-omit-frame-pointer")
+    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
+    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address")
+endif()
+
 file(GLOB_RECURSE SGCL_SOURCES "sgcl/*.h")
 add_library(sgcl INTERFACE
     ${SGCL_SOURCES}
diff --git a/examples/lock_free_stack.cpp b/examples/lock_free_stack.cpp
index 839bcac..25f25f1 100644
--- a/examples/lock_free_stack.cpp
+++ b/examples/lock_free_stack.cpp
@@ -3,6 +3,7 @@
 #include <chrono>
 #include <future>
 #include <iostream>
+#include <optional>
 
 template<typename T>
 class LockFreeStack {
diff --git a/sgcl/detail/child_pointers.h b/sgcl/detail/child_pointers.h
index 53d9ea4..3e43e7e 100644
--- a/sgcl/detail/child_pointers.h
+++ b/sgcl/detail/child_pointers.h
@@ -17,7 +17,7 @@ namespace sgcl::detail {
         using Map = std::vector<std::atomic<uint8_t>>;
         using Vector = std::vector<ptrdiff_t>;
 
-        constexpr ChildPointers(bool f, size_t object_size) noexcept
+        ChildPointers(bool f, size_t object_size) noexcept
         : final(f)
         , map(f ? 0 : (object_size + sizeof(RawPointer) * 8 - 1) / (sizeof(RawPointer) * 8)) {
         };

Then build and run the lock-free stack example as follows:

mkdir build
cd build
cmake -DENABLE_ASAN=ON ..
cmake --build . --target lock_free_stack
./examples/lock_free_stack

ASan reports an error similar to the following:

=================================================================
==367814==ERROR: AddressSanitizer: new-delete-type-mismatch on 0x522000000100 in thread T5:
  object passed to delete has wrong type:
  size of the allocated type:   5752 bytes;
  size of the deallocated type: 120 bytes.
    #0 0x7c1a7a4b724f in operator delete(void*, unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:172
    #1 0x5822181c6c79 in sgcl::detail::Collector::_release_unused_pages()::{lambda()#1}::operator()() const /home/hyeon/Repository/sgcl/sgcl/detail/collector.h:688
    #2 0x5822181efe78 in void std::__invoke_impl<void, sgcl::detail::Collector::_release_unused_pages()::{lambda()#1}>(std::__invoke_other, sgcl::detail::Collector::_release_unused_pages()::{lambda()#1}&&) /usr/include/c++/11/bits/invoke.h:61
    #3 0x5822181efd56 in std::__invoke_result<sgcl::detail::Collector::_release_unused_pages()::{lambda()#1}>::type std::__invoke<sgcl::detail::Collector::_release_unused_pages()::{lambda()#1}>(sgcl::detail::Collector::_release_unused_pages()::{lambda()#1}&&) /usr/include/c++/11/bits/invoke.h:96
    #4 0x5822181efc25 in void std::thread::_Invoker<std::tuple<sgcl::detail::Collector::_release_unused_pages()::{lambda()#1}> >::_M_invoke<0ul>(std::_Index_tuple<0ul>) /usr/include/c++/11/bits/std_thread.h:259
    #5 0x5822181ef6f5 in std::thread::_Invoker<std::tuple<sgcl::detail::Collector::_release_unused_pages()::{lambda()#1}> >::operator()() /usr/include/c++/11/bits/std_thread.h:266
    #6 0x5822181ee9af in std::thread::_State_impl<std::thread::_Invoker<std::tuple<sgcl::detail::Collector::_release_unused_pages()::{lambda()#1}> > >::_M_run() /usr/include/c++/11/bits/std_thread.h:211
    #7 0x7c1a7a0dc252  (/lib/x86_64-linux-gnu/libstdc++.so.6+0xdc252)
    #8 0x7c1a79c94ac2 in start_thread nptl/pthread_create.c:442
    #9 0x7c1a79d268bf  (/lib/x86_64-linux-gnu/libc.so.6+0x1268bf)

0x522000000100 is located 0 bytes inside of 5752-byte region [0x522000000100,0x522000001778)
allocated by thread T1 here:
    #0 0x7c1a7a4b61e7 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:99
    #1 0x5822181ee772 in sgcl::detail::ObjectPoolAllocator<LockFreeStack<int>::Node>::_create_page_parameters(sgcl::detail::DataPage*) /home/hyeon/Repository/sgcl/sgcl/detail/object_pool_allocator.h:32
    #2 0x5822181c0f21 in sgcl::detail::ObjectPoolAllocatorBase::_alloc_page() /home/hyeon/Repository/sgcl/sgcl/detail/object_pool_allocator_base.h:64
    #3 0x5822181c0b8b in sgcl::detail::ObjectPoolAllocatorBase::alloc(unsigned long) /home/hyeon/Repository/sgcl/sgcl/detail/object_pool_allocator_base.h:43
    #4 0x5822181e220a in std::unique_ptr<LockFreeStack<int>::Node, sgcl::detail::UniqueDeleter> sgcl::detail::Maker<LockFreeStack<int>::Node>::_make<int>(int&&) /home/hyeon/Repository/sgcl/sgcl/detail/maker.h:90
    #5 0x5822181db25f in std::unique_ptr<LockFreeStack<int>::Node, sgcl::detail::UniqueDeleter> sgcl::detail::Maker<LockFreeStack<int>::Node>::make_tracked<int>(int&&) /home/hyeon/Repository/sgcl/sgcl/detail/maker.h:74
    #6 0x5822181d1e47 in auto sgcl::make_tracked<LockFreeStack<int>::Node, int, 0>(int&&) /home/hyeon/Repository/sgcl/sgcl/make_tracked.h:15
    #7 0x5822181d1fef in LockFreeStack<int>::push(int) /home/hyeon/Repository/sgcl/examples/lock_free_stack.cpp:25
    #8 0x5822181b0db1 in operator() /home/hyeon/Repository/sgcl/examples/lock_free_stack.cpp:61
    #9 0x5822181b9619 in __invoke_impl<long int, main()::<lambda()> > /usr/include/c++/11/bits/invoke.h:61
    #10 0x5822181b958b in __invoke<main()::<lambda()> > /usr/include/c++/11/bits/invoke.h:96
    #11 0x5822181b950f in _M_invoke<0> /usr/include/c++/11/bits/std_thread.h:259
    #12 0x5822181b93f7 in operator() /usr/include/c++/11/bits/std_thread.h:266
    #13 0x5822181b8c17 in operator() /usr/include/c++/11/future:1386
    #14 0x5822181b88ef in __invoke_impl<std::unique_ptr<std::__future_base::_Result<long int>, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<long int>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<main()::<lambda()> > >, long int>&> /usr/include/c++/11/bits/invoke.h:61
    #15 0x5822181b82a1 in __invoke_r<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<long int>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<main()::<lambda()> > >, long int>&> /usr/include/c++/11/bits/invoke.h:116
    #16 0x5822181b7d76 in _M_invoke /usr/include/c++/11/bits/std_function.h:291
    #17 0x5822181d1781 in std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>::operator()() const /usr/include/c++/11/bits/std_function.h:590
    #18 0x5822181c9f20 in std::__future_base::_State_baseV2::_M_do_set(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*) /usr/include/c++/11/future:571
    #19 0x5822181e1606 in void std::__invoke_impl<void, void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::__invoke_memfun_deref, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) /usr/include/c++/11/bits/invoke.h:74
    #20 0x5822181da564 in std::__invoke_result<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>::type std::__invoke<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) /usr/include/c++/11/bits/invoke.h:96
    #21 0x5822181d12b9 in std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#1}::operator()() const /usr/include/c++/11/mutex:776
    #22 0x5822181da594 in std::once_flag::_Prepare_execution::_Prepare_execution<std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#1}>(void (std::__future_base::_State_baseV2::*&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*))::{lambda()#1}::operator()() const /usr/include/c++/11/mutex:712
    #23 0x5822181da5a9 in std::once_flag::_Prepare_execution::_Prepare_execution<std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#1}>(void (std::__future_base::_State_baseV2::*&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*))::{lambda()#1}::_FUN() /usr/include/c++/11/mutex:712
    #24 0x7c1a79c99ee7 in __pthread_once_slow nptl/pthread_once.c:116

Thread T5 created by T3 here:
    #0 0x7c1a7a458685 in __interceptor_pthread_create ../../../../src/libsanitizer/asan/asan_interceptors.cpp:216
    #1 0x7c1a7a0dc328 in std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (/lib/x86_64-linux-gnu/libstdc++.so.6+0xdc328)
    #2 0x5822181c7b82 in sgcl::detail::Collector::_release_unused_pages() /home/hyeon/Repository/sgcl/sgcl/detail/collector.h:686
    #3 0x5822181c8237 in sgcl::detail::Collector::_main_loop() /home/hyeon/Repository/sgcl/sgcl/detail/collector.h:729
    #4 0x5822181c324b in sgcl::detail::Collector::Collector()::{lambda()#1}::operator()() const /home/hyeon/Repository/sgcl/sgcl/detail/collector.h:28
    #5 0x5822181efebd in void std::__invoke_impl<void, sgcl::detail::Collector::Collector()::{lambda()#1}>(std::__invoke_other, sgcl::detail::Collector::Collector()::{lambda()#1}&&) /usr/include/c++/11/bits/invoke.h:61
    #6 0x5822181efdb5 in std::__invoke_result<sgcl::detail::Collector::Collector()::{lambda()#1}>::type std::__invoke<sgcl::detail::Collector::Collector()::{lambda()#1}>(sgcl::detail::Collector::Collector()::{lambda()#1}&&) /usr/include/c++/11/bits/invoke.h:96
    #7 0x5822181efc55 in void std::thread::_Invoker<std::tuple<sgcl::detail::Collector::Collector()::{lambda()#1}> >::_M_invoke<0ul>(std::_Index_tuple<0ul>) /usr/include/c++/11/bits/std_thread.h:259
    #8 0x5822181ef715 in std::thread::_Invoker<std::tuple<sgcl::detail::Collector::Collector()::{lambda()#1}> >::operator()() /usr/include/c++/11/bits/std_thread.h:266
    #9 0x5822181ee9d3 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<sgcl::detail::Collector::Collector()::{lambda()#1}> > >::_M_run() /usr/include/c++/11/bits/std_thread.h:211
    #10 0x7c1a7a0dc252  (/lib/x86_64-linux-gnu/libstdc++.so.6+0xdc252)

Thread T3 created by T1 here:
    #0 0x7c1a7a458685 in __interceptor_pthread_create ../../../../src/libsanitizer/asan/asan_interceptors.cpp:216
    #1 0x7c1a7a0dc328 in std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (/lib/x86_64-linux-gnu/libstdc++.so.6+0xdc328)
    #2 0x5822181c3695 in sgcl::detail::Collector::Collector() /home/hyeon/Repository/sgcl/sgcl/detail/collector.h:28
    #3 0x5822181c8d10 in sgcl::detail::collector_instance() /home/hyeon/Repository/sgcl/sgcl/detail/collector.h:859
    #4 0x5822181c8d85 in sgcl::detail::collector_init() /home/hyeon/Repository/sgcl/sgcl/detail/collector.h:864
    #5 0x5822181bded4 in sgcl::detail::ObjectAllocatorBase::ObjectAllocatorBase(std::atomic<sgcl::detail::Page*>&) /home/hyeon/Repository/sgcl/sgcl/detail/object_allocator_base.h:15
    #6 0x5822181c059c in sgcl::detail::ObjectPoolAllocatorBase::ObjectPoolAllocatorBase(sgcl::detail::BlockAllocator&, std::atomic<sgcl::detail::Page*>&, sgcl::detail::PointerPoolBase&, std::atomic<sgcl::detail::Page*>&) /home/hyeon/Repository/sgcl/sgcl/detail/object_pool_allocator_base.h:18
    #7 0x5822181ea73c in sgcl::detail::ObjectPoolAllocator<LockFreeStack<int>::Node>::ObjectPoolAllocator(sgcl::detail::BlockAllocator&, std::atomic<sgcl::detail::Page*>&) /home/hyeon/Repository/sgcl/sgcl/detail/object_pool_allocator.h:18
    #8 0x5822181e6aea in sgcl::detail::ObjectPoolAllocator<LockFreeStack<int>::Node>& sgcl::detail::Thread::_allocator<sgcl::detail::ObjectPoolAllocator<LockFreeStack<int>::Node> >() /home/hyeon/Repository/sgcl/sgcl/detail/thread.h:140
    #9 0x5822181e20d9 in auto& sgcl::detail::Thread::alocator<LockFreeStack<int>::Node>() /home/hyeon/Repository/sgcl/sgcl/detail/thread.h:105
    #10 0x5822181e21ef in std::unique_ptr<LockFreeStack<int>::Node, sgcl::detail::UniqueDeleter> sgcl::detail::Maker<LockFreeStack<int>::Node>::_make<int>(int&&) /home/hyeon/Repository/sgcl/sgcl/detail/maker.h:89
    #11 0x5822181db25f in std::unique_ptr<LockFreeStack<int>::Node, sgcl::detail::UniqueDeleter> sgcl::detail::Maker<LockFreeStack<int>::Node>::make_tracked<int>(int&&) /home/hyeon/Repository/sgcl/sgcl/detail/maker.h:74
    #12 0x5822181d1e47 in auto sgcl::make_tracked<LockFreeStack<int>::Node, int, 0>(int&&) /home/hyeon/Repository/sgcl/sgcl/make_tracked.h:15
    #13 0x5822181d1fef in LockFreeStack<int>::push(int) /home/hyeon/Repository/sgcl/examples/lock_free_stack.cpp:25
    #14 0x5822181b0db1 in operator() /home/hyeon/Repository/sgcl/examples/lock_free_stack.cpp:61
    #15 0x5822181b9619 in __invoke_impl<long int, main()::<lambda()> > /usr/include/c++/11/bits/invoke.h:61
    #16 0x5822181b958b in __invoke<main()::<lambda()> > /usr/include/c++/11/bits/invoke.h:96
    #17 0x5822181b950f in _M_invoke<0> /usr/include/c++/11/bits/std_thread.h:259
    #18 0x5822181b93f7 in operator() /usr/include/c++/11/bits/std_thread.h:266
    #19 0x5822181b8c17 in operator() /usr/include/c++/11/future:1386
    #20 0x5822181b88ef in __invoke_impl<std::unique_ptr<std::__future_base::_Result<long int>, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<long int>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<main()::<lambda()> > >, long int>&> /usr/include/c++/11/bits/invoke.h:61
    #21 0x5822181b82a1 in __invoke_r<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<long int>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<main()::<lambda()> > >, long int>&> /usr/include/c++/11/bits/invoke.h:116
    #22 0x5822181b7d76 in _M_invoke /usr/include/c++/11/bits/std_function.h:291
    #23 0x5822181d1781 in std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>::operator()() const /usr/include/c++/11/bits/std_function.h:590
    #24 0x5822181c9f20 in std::__future_base::_State_baseV2::_M_do_set(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*) /usr/include/c++/11/future:571
    #25 0x5822181e1606 in void std::__invoke_impl<void, void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::__invoke_memfun_deref, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) /usr/include/c++/11/bits/invoke.h:74
    #26 0x5822181da564 in std::__invoke_result<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>::type std::__invoke<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) /usr/include/c++/11/bits/invoke.h:96
    #27 0x5822181d12b9 in std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#1}::operator()() const /usr/include/c++/11/mutex:776
    #28 0x5822181da594 in std::once_flag::_Prepare_execution::_Prepare_execution<std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#1}>(void (std::__future_base::_State_baseV2::*&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*))::{lambda()#1}::operator()() const /usr/include/c++/11/mutex:712
    #29 0x5822181da5a9 in std::once_flag::_Prepare_execution::_Prepare_execution<std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#1}>(void (std::__future_base::_State_baseV2::*&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*))::{lambda()#1}::_FUN() /usr/include/c++/11/mutex:712
    #30 0x7c1a79c99ee7 in __pthread_once_slow nptl/pthread_once.c:116

Thread T1 created by T0 here:
    #0 0x7c1a7a458685 in __interceptor_pthread_create ../../../../src/libsanitizer/asan/asan_interceptors.cpp:216
    #1 0x7c1a7a0dc328 in std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (/lib/x86_64-linux-gnu/libstdc++.so.6+0xdc328)
    #2 0x5822181b633b in _Async_state_impl<main()::<lambda()> > /usr/include/c++/11/future:1730
    #3 0x5822181b59ec in construct_at<std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<main()::<lambda()> > >, long int>, main()::<lambda()> > /usr/include/c++/11/bits/stl_construct.h:97
    #4 0x5822181b5a50 in construct<std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<main()::<lambda()> > >, long int>, main()::<lambda()> > /usr/include/c++/11/bits/alloc_traits.h:518
    #5 0x5822181b4b99 in _Sp_counted_ptr_inplace<main()::<lambda()> > /usr/include/c++/11/bits/shared_ptr_base.h:519
    #6 0x5822181b3c02 in __shared_count<std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<main()::<lambda()> > >, long int>, std::allocator<std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<main()::<lambda()> > >, long int> >, main()::<lambda()> > /usr/include/c++/11/bits/shared_ptr_base.h:650
    #7 0x5822181b347b in __shared_ptr<std::allocator<std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<main()::<lambda()> > >, long int> >, main()::<lambda()> > /usr/include/c++/11/bits/shared_ptr_base.h:1342
    #8 0x5822181b2c42 in shared_ptr<std::allocator<std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<main()::<lambda()> > >, long int> >, main()::<lambda()> > /usr/include/c++/11/bits/shared_ptr.h:409
    #9 0x5822181b2520 in allocate_shared<std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<main()::<lambda()> > >, long int>, std::allocator<std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<main()::<lambda()> > >, long int> >, main()::<lambda()> > /usr/include/c++/11/bits/shared_ptr.h:863
    #10 0x5822181b1ede in make_shared<std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<main()::<lambda()> > >, long int>, main()::<lambda()> > /usr/include/c++/11/bits/shared_ptr.h:879
    #11 0x5822181b16d9 in async<main()::<lambda()> > /usr/include/c++/11/future:1779
    #12 0x5822181b1441 in async<main()::<lambda()> > /usr/include/c++/11/future:1806
    #13 0x5822181b0fcf in main /home/hyeon/Repository/sgcl/examples/lock_free_stack.cpp:65
    #14 0x7c1a79c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

SUMMARY: AddressSanitizer: new-delete-type-mismatch ../../../../src/libsanitizer/asan/asan_new_delete.cpp:172 in operator delete(void*, unsigned long)
==367814==HINT: if you don't care about these errors you may set ASAN_OPTIONS=new_delete_type_mismatch=0
==367814==ABORTING

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions