We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I wrote the following test program:
void test_concurrent_inserts_and_deletes(RBTree<int, int>& map) { std::vector<std::thread> threads; int num_threads = 10; int operations_per_thread = 1000; for (int i = 0; i < num_threads; ++i) { threads.emplace_back([&]() { for (int j = 0; j < operations_per_thread; ++j) { map.Insert(j, 10); map.Remove(j); } }); } for (auto& thread : threads) { thread.join(); } }
This was the output running with address sanitization:
==17418==ERROR: AddressSanitizer: heap-use-after-free on address 0x602000002050 at pc 0x000000515b79 bp 0x7f3d644fd990 sp 0x7f3d644fd988 READ of size 8 at 0x602000002050 thread T2 #0 0x515b78 in std::__atomic_base<DataNode<int, int>*>::operator DataNode<int, int>*() const (/home/markt/CLionProjects/test_rbtree/cmake-build-debug/test_rbtree+0x515b78) #1 0x510a0d in std::atomic<DataNode<int, int>*>::operator DataNode<int, int>*() const (/home/markt/CLionProjects/test_rbtree/cmake-build-debug/test_rbtree+0x510a0d) #2 0x511973 in TreeNode<int, int>::GetData() (/home/markt/CLionProjects/test_rbtree/cmake-build-debug/test_rbtree+0x511973) #3 0x51044d in TreeNode<int, int>::swap_window(TreeNode<int, int>*, DataNode<int, int>*) (/home/markt/CLionProjects/test_rbtree/cmake-build-debug/test_rbtree+0x51044d) #4 0x50e84c in RBTree<int, int>::Remove(int) (/home/markt/CLionProjects/test_rbtree/cmake-build-debug/test_rbtree+0x50e84c) #5 0x50ada9 in operator() /home/markt/CLionProjects/test_rbtree/main.cpp:20 #6 0x50bee5 in __invoke_impl<void, test_concurrent_inserts_and_deletes(RBTree<int, int>&)::<lambda()> > /usr/include/c++/13.2.0/bits/invoke.h:61 #7 0x50bea8 in __invoke<test_concurrent_inserts_and_deletes(RBTree<int, int>&)::<lambda()> > /usr/include/c++/13.2.0/bits/invoke.h:96 #8 0x50be55 in _M_invoke<0> /usr/include/c++/13.2.0/bits/std_thread.h:292 #9 0x50be29 in operator() /usr/include/c++/13.2.0/bits/std_thread.h:299 #10 0x50be0d in _M_run /usr/include/c++/13.2.0/bits/std_thread.h:244 #11 0x7f3d67c2f452 (/usr/lib64/libstdc++.so.6+0xe4452) #12 0x7f3d67873d56 in start_thread (/lib64/libc.so.6+0x94d56) #13 0x7f3d678f86a7 in __clone3 (/lib64/libc.so.6+0x1196a7) 0x602000002050 is located 0 bytes inside of 8-byte region [0x602000002050,0x602000002058) freed by thread T2 here: #0 0x4bb938 in operator delete(void*, unsigned long) (/home/markt/CLionProjects/test_rbtree/cmake-build-debug/test_rbtree+0x4bb938) #1 0x5142b8 in RBTree<int, int>::fix_delete(std::vector<TreeNode<int, int>*, std::allocator<TreeNode<int, int>*> >&) (/home/markt/CLionProjects/test_rbtree/cmake-build-debug/test_rbtree+0x5142b8) #2 0x5102c6 in RBTree<int, int>::fix_window_color(std::vector<TreeNode<int, int>*, std::allocator<TreeNode<int, int>*> >&, int) (/home/markt/CLionProjects/test_rbtree/cmake-build-debug/test_rbtree+0x5102c6) #3 0x50e834 in RBTree<int, int>::Remove(int) (/home/markt/CLionProjects/test_rbtree/cmake-build-debug/test_rbtree+0x50e834) #4 0x50ada9 in operator() /home/markt/CLionProjects/test_rbtree/main.cpp:20 #5 0x50bee5 in __invoke_impl<void, test_concurrent_inserts_and_deletes(RBTree<int, int>&)::<lambda()> > /usr/include/c++/13.2.0/bits/invoke.h:61 #6 0x50bea8 in __invoke<test_concurrent_inserts_and_deletes(RBTree<int, int>&)::<lambda()> > /usr/include/c++/13.2.0/bits/invoke.h:96 #7 0x50be55 in _M_invoke<0> /usr/include/c++/13.2.0/bits/std_thread.h:292 #8 0x50be29 in operator() /usr/include/c++/13.2.0/bits/std_thread.h:299 #9 0x50be0d in _M_run /usr/include/c++/13.2.0/bits/std_thread.h:244 #10 0x7f3d67c2f452 (/usr/lib64/libstdc++.so.6+0xe4452)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I wrote the following test program:
This was the output running with address sanitization:
The text was updated successfully, but these errors were encountered: