3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-07-12 15:36:39 +00:00
Commit graph

19628 commits

Author SHA1 Message Date
Nikolaj Bjorner
a0c2a6a92b
Update scoped_ctrl_c.cpp
remove stale field
2025-05-18 16:24:49 -07:00
Nikolaj Bjorner
78c5800a99
Merge branch 'master' into ctrl-c-races 2025-04-19 13:58:13 -07:00
Nikolaj Bjorner
cc1bb0a255 remove superfluous makefile
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2025-04-19 13:56:30 -07:00
Nikolaj Bjorner
17cac7d87c provide shortcut to command-line version to retrieve parameters
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2025-04-19 13:51:08 -07:00
Nikolaj Bjorner
6e88d91214 add badge for ocaml cmake
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2025-04-19 13:46:40 -07:00
Nikolaj Bjorner
3761dd869a address build warning with overloaded virtual operators
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2025-04-19 13:42:11 -07:00
Shiwei Weng 翁士伟
f7aec02503
WIP: Migrating OCaml binding to CMake (#7254)
* Update doc for `mk_context`.

* Migrating to cmake.

* Migrating to cmake. It builds both internal or external libz3.

* Start to work on platform-specific problem.

* Messy notes.

* debug.

* Cleanup a bit.

* Fixing shared lib extension.

* Minor.

* Resume working on this PR.

* Remove including `AddOCaml`.

* Keep `z3.ml` and `z3.mli` in the src but specify the generated file in the bin.

* Keep `ml_example.ml` in the src.

* Try github action for ocaml.

* Add workflow using matrix.

* Fix mac linking once more.

* Bypass @rpath in building sanity check.
2025-04-19 13:41:27 -07:00
Lev Nachmanson
ab9f3307d6 change the default of running dio to true, and running gcd to false, remove branching in dio
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2025-04-18 18:24:50 -07:00
Lev Nachmanson
dbde713eb3 remove testing code in is_big_term_on_no_term
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2025-04-18 18:24:50 -07:00
Lev Nachmanson
1131d5294d fix a bug in tracking the changes in dio
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2025-04-18 18:24:50 -07:00
Lev Nachmanson
d289495ca4 allow gcd when dio ignores some terms
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2025-04-18 18:24:50 -07:00
Lev Nachmanson
17af18fe31 make gcd call in dio optional
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2025-04-18 18:24:50 -07:00
Lev Nachmanson
436eefbce2 always remove the tightened term
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2025-04-18 18:24:50 -07:00
Lev Nachmanson
dc7185d0a4 change the name of m_changed_columns to m_changed_f_columns
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2025-04-18 18:24:50 -07:00
Lev Nachmanson
32e77d8214 typo
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2025-04-18 18:24:50 -07:00
Lev Nachmanson
cb1818f4b8 reject more terms with big numbers
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2025-04-18 18:24:50 -07:00
Lev Nachmanson
1cde40bddb dio_calls_period=4 2025-04-18 18:24:50 -07:00
Lev Nachmanson
87e2ce8948 Update lp_settings.h - m_dio_calls_period = 4 2025-04-18 18:24:50 -07:00
Lev Nachmanson
59edb81f86 Update lp_settings.cpp
white space change
2025-04-18 18:24:50 -07:00
Lev Nachmanson
8db9f52386 add parameter m_dio_calls_period
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2025-04-18 18:24:50 -07:00
Lev Nachmanson
ae97ee09d9 throttle dio
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2025-04-18 18:24:50 -07:00
Lev Nachmanson
972f80188a throttle dio for big numbers
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2025-04-18 18:24:50 -07:00
Lev Nachmanson
3e49d9fcfe reuse dio branch
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2025-04-18 18:24:50 -07:00
mikulas-patocka
e31e9819b1
Add an option "ctrl_c" that can be used to disable Ctrl-C signal handling (#7619)
Add this option, so that the z3 library can be used in programs that do
signal handling on their own.

Signed-off-by: Mikulas Patocka <mikulas@twibright.com>
2025-04-18 10:34:54 -07:00
Nikolaj Bjorner
ed5dd26bb7 remove non-working ts mcp server, settle with python variant 2025-04-18 10:10:12 -07:00
Nikolaj Bjorner
741cb5c3b5 minimal z3 MCP server 2025-04-18 10:00:04 -07:00
Nikolaj Bjorner
f63c9e366f disable assignment for param_descrs 2025-04-17 17:29:09 -07:00
Nikolaj Bjorner
3f73c8b18f stab at SMTLIB REL mcp server 2025-04-17 17:23:09 -07:00
Nikolaj Bjorner
755f57931b fix #7622 2025-04-17 11:05:49 -07:00
Nikolaj Bjorner
81f10912ae remove unused bdd based variable elimination 2025-04-14 16:07:41 -07:00
Nikolaj Bjorner
e41090df83 fix #7602
add missing relevancy propagation so that relationship between rel and TC(rel) are not lost to the theory solver.
2025-04-14 15:38:22 -07:00
Nikolaj Bjorner
8035edbe65 remove lp_assert 2025-04-14 11:10:26 -07:00
Nikolaj Bjorner
1510b3112e fix build warnings 2025-04-14 10:34:09 -07:00
Kyle Bloom
5ad79f2864
Add Iterators as acceptable arguments to functions (#7620) 2025-04-12 10:32:56 -07:00
mikulas-patocka
6ecc7a2dd4
Fix a race condition in scoped_timer::finalize (#7618)
scoped_timer::finalize is called from fork. However, it may race with
other threads creating or freeing timer threads.

This patch removes the loop in scoped_timer::finalize (because it is not
needed and it may spin) and also removes two unlocked assignments.

The idle thread is added to "available_workers" in
scoped_timer::~scoped_timer destructor.

If we call the "finalize" method as a part of total memory cleanup, all
the scoped_timers' destructors were already executed and all the worker
threads are already on "available_workers" vector. So, we don't need to
loop; the first loop iteration will clean all the threads.

If the "finalize" method is called from single-threaded program's fork(),
then all the scoped timers' destructors are already called and the case
is analogous to the previous case.

If the "finalize" method is called from multi-threaded program's fork(),
then it breaks down - the "num_workers" variable is the total amount of
workers (both sleeping and busy), and we loop until we terminated
"num_workers" threads - that means that if the number of sleeping workers
is less than "num_workers", the function just spins.

Then, there is unlocked assignment to "num_workers = 0" and
"available_workers.clear()" that can race with other threads doing z3
work and corrupt memory. available_workers.clear() is not needed, because
it was already cleared by std::swap(available_workers, cleanup_workers)
(and that was correctly locked).

Signed-off-by: Mikulas Patocka <mikulas@twibright.com>
2025-04-11 08:08:27 +01:00
Nikolaj Bjorner
a83efa68eb spacing 2025-04-09 20:24:09 -07:00
Nikolaj Bjorner
8138829231 fix #7616 2025-04-09 20:24:09 -07:00
Mikulas Patocka
bcd615f3c5 Make Ctrl-C handling thread-safe (#7603)
The Ctrl-C handling is not thread safe, there's a global variable g_obj
that is being accessed without any locking. The signal handlers are
per-process, not per-thread, so that different threads step over each
other's handlers. It is unpredictable in which thread the signal handler
runs, so the handler may race with the scoped_ctrl_c destructor.

Fix this by introducing the functions signal_lock and signal_unlock.
signal_lock blocks the SIGINT signal and then takes a mutex (so that the
signal handler can't be called while the mutex is held). signal_unlock
drops the mutex and restores the signal mask.

We protect all the global variables with signal_lock and signal_unlock.

Note that on Windows, the SIGINT handler is being run in a separate
thread (and there is no way how to block it), so we can use a simple
mutex to synchronize the signal handler with the other threads.

In class cancel_eh, the operator () may be called concurrently by the
timer code and the Ctrl-C code, but the operator () accesses class'
members without any locking. Fix this race condition by using the
functions signal_lock() and signal_unlock().

There is this possible call trace:
        SIGINT signal
        on_sigint
        a->m_cancel_eh()
        cancel_eh::operator()
        m_obj.inc_cancel
        reslimit::inc_cancel
        lock_guard lock(*g_rlimit_mux);

Here we take a mutex from a signal - this is subject to deadlock (if the
signal interrupted another piece of code where the mutex is already
held).

To fix this race, we remove g_rlimit_mux and replace it with
signal_lock() and signal_unlock(). signal_lock and signal_unlock block
the signal before grabbing the mutex, so the signal can't interrupt a
piece of code where the mutex is held and the deadlock won't happen.

Signed-off-by: Mikulas Patocka <mikulas@twibright.com>
2025-04-09 18:35:28 +02:00
Josh Berdine
d792840739
Add Z3_is_recursive_datatype_sort to the API (#7615)
It does not seem to be possible to test if a datatype sort is recursive.
2025-04-08 14:36:57 -07:00
Mark Ryan
14e2aadad0
include LICENSE.txt in wheels (#7614)
Update setup.py so that we copy LICENSE.TXT to src/api/python before
creating the sdist.  Any wheels built from this sdist will now
contain the LICENSE.txt file.

Fixes #7604
2025-04-07 08:41:50 -07:00
Nikolaj Bjorner
0b7a81b7c9 list[ExprRef] doesn't build for python 2025-04-05 14:45:52 -07:00
Nikolaj Bjorner
2b6055040b update agentz3 sample based on hugging face training/test data
https://huggingface.co/datasets/CardinalOperations/IndustryOR/blob/main/IndustryOR.json
2025-04-05 14:43:30 -07:00
Nikolaj Bjorner
e7ff6009a0 #7605
add case for linux/risc64
2025-04-05 12:07:46 -07:00
Nikolaj Bjorner
a39efbb008 fix #7607 2025-04-05 11:58:47 -07:00
Nikolaj Bjorner
9d8291a75b remove type annotation Context | None to ensure Centos ARM Build pass 2025-04-05 10:51:35 -07:00
Nikolaj Bjorner
f607331856 type annotations across Python versions
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2025-04-04 22:14:32 -07:00
Nikolaj Bjorner
bd2c7aa908 remove downlevel version incompatible elements of typing 2025-04-04 20:18:23 -07:00
Nikolaj Bjorner
305f1e8498 remove references to TypeGuard
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2025-04-04 19:41:50 -07:00
Nikolaj Bjorner
a5048e4563 add initial sample agent use case 2025-04-04 18:40:15 -07:00
Nikolaj Bjorner
0a3719447e fix #7609 2025-04-04 18:40:15 -07:00