From ef80645a71e2e46190bf631e7f5a345315b132cb Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Wed, 14 Oct 2015 22:13:43 +0100 Subject: [PATCH] Java API context deletion concurrency fix. Relates to #205 #245 --- src/api/java/Context.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/api/java/Context.java b/src/api/java/Context.java index 56f9e008c..1bc01857b 100644 --- a/src/api/java/Context.java +++ b/src/api/java/Context.java @@ -3809,14 +3809,16 @@ public class Context extends IDisposable m_intSort = null; m_realSort = null; - if (m_refCount.get() == 0 && m_ctx != 0) { - try { - Native.delContext(m_ctx); - } catch (Z3Exception e) { - // OK? - System.out.println("Context deletion failed; memory leak possible."); + synchronized (creation_lock) { + if (m_refCount.get() == 0 && m_ctx != 0) { + try { + Native.delContext(m_ctx); + } catch (Z3Exception e) { + // OK? + System.out.println("Context deletion failed; memory leak possible."); + } + m_ctx = 0; } - m_ctx = 0; } } }