From 0f18dd8be6b20ebb8b6e5904032cc7ead305e88c Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Thu, 8 Feb 2024 13:10:29 -0500 Subject: Added compiler fence to block reordering I'm reasonably certain that this is a compiler bug... --- CMakeLists.txt | 4 ++-- include/shard/ISAMTree.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f77396..be0fb15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) set(namespace "de") project("Practical Dynamic Extension" VERSION 0.1.0) -set(debug true) +set(debug false) set(tests True) set(bench true) set(old_bench False) @@ -25,7 +25,7 @@ if (debug) add_compile_options(-fsanitize=undefined) add_link_options(-fsanitize=undefined) else() - add_compile_options(-g -O3) + add_compile_options(-O3) endif() # Test build instructions diff --git a/include/shard/ISAMTree.h b/include/shard/ISAMTree.h index 33ba82f..b52887a 100644 --- a/include/shard/ISAMTree.h +++ b/include/shard/ISAMTree.h @@ -65,6 +65,8 @@ public: sizeof(Wrapped), (byte**) &m_data); + asm volatile ("" ::: "memory"); + auto res = sorted_array_from_bufferview(std::move(buffer), m_data, m_bf); m_reccnt = res.record_count; m_tombstone_cnt = res.tombstone_count; -- cgit v1.2.3 From ed724dc3c380df36d8198ad27a63bf392c077ea7 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Thu, 8 Feb 2024 13:13:33 -0500 Subject: ISAMTree: added comment explaining the compiler fence --- include/shard/ISAMTree.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/shard/ISAMTree.h b/include/shard/ISAMTree.h index b52887a..9458b1f 100644 --- a/include/shard/ISAMTree.h +++ b/include/shard/ISAMTree.h @@ -65,6 +65,10 @@ public: sizeof(Wrapped), (byte**) &m_data); + /* + * without this, gcc seems to hoist the building of the array + * _above_ its allocation under -O3, resulting in memfaults. + */ asm volatile ("" ::: "memory"); auto res = sorted_array_from_bufferview(std::move(buffer), m_data, m_bf); -- cgit v1.2.3