mirror of
https://github.com/Z3Prover/z3
synced 2025-12-25 21:46:51 +00:00
Fix race condition in ast_manager::update_fresh_id
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
parent
ed695cfe20
commit
2875341588
3 changed files with 13 additions and 2 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -115,3 +115,5 @@ genaisrc/genblogpost.genai.mts
|
|||
*.mts
|
||||
# Bazel generated files
|
||||
bazel-*
|
||||
# Test binaries
|
||||
test_translate_race
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ Revision History:
|
|||
#include "util/dependency.h"
|
||||
#include "util/rlimit.h"
|
||||
#include <variant>
|
||||
#include <atomic>
|
||||
|
||||
#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<unsigned> m_fresh_id;
|
||||
bool m_debug_ref_count;
|
||||
u_map<unsigned> m_debug_free_indices;
|
||||
std::fstream* m_trace_stream = nullptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue