From 0c4a80b90e1f25b42e00a8af57131040203d2f89 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... --- include/shard/ISAMTree.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include/shard/ISAMTree.h') diff --git a/include/shard/ISAMTree.h b/include/shard/ISAMTree.h index 33ba82f..9458b1f 100644 --- a/include/shard/ISAMTree.h +++ b/include/shard/ISAMTree.h @@ -65,6 +65,12 @@ 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); m_reccnt = res.record_count; m_tombstone_cnt = res.tombstone_count; -- cgit v1.2.3