diff --git a/.gitignore b/.gitignore index 8104503a8..e7979fbdc 100644 --- a/.gitignore +++ b/.gitignore @@ -115,3 +115,5 @@ genaisrc/genblogpost.genai.mts *.mts # Bazel generated files bazel-* +# Test binaries +test_translate_race diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index 6e2f2e6af..a6d65d098 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -1316,7 +1316,15 @@ ast_manager::ast_manager(ast_manager const & src, bool disable_proofs): } void ast_manager::update_fresh_id(ast_manager const& m) { - m_fresh_id = std::max(m_fresh_id, m.m_fresh_id); + unsigned other_id = m.m_fresh_id.load(std::memory_order_relaxed); + unsigned current_id = m_fresh_id.load(std::memory_order_relaxed); + while (other_id > current_id) { + if (m_fresh_id.compare_exchange_weak(current_id, other_id, + std::memory_order_relaxed, + std::memory_order_relaxed)) { + break; + } + } } diff --git a/src/ast/ast.h b/src/ast/ast.h index 9dd564206..bab25c075 100644 --- a/src/ast/ast.h +++ b/src/ast/ast.h @@ -48,6 +48,7 @@ Revision History: #include "util/dependency.h" #include "util/rlimit.h" #include +#include #define RECYCLE_FREE_AST_INDICES @@ -1518,7 +1519,7 @@ protected: app * m_true; app * m_false; proof * m_undef_proof; - unsigned m_fresh_id; + std::atomic m_fresh_id; bool m_debug_ref_count; u_map m_debug_free_indices; std::fstream* m_trace_stream = nullptr;