3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-08-07 06:28:18 +00:00
z3/src/api
Copilot 4fd22680b5
Go bindings: enable concurrent dec_ref for GC-driven finalizers (#10002)
The Go bindings rely on finalizers to release Z3 references, which can
run during concurrent GC and trigger unsafe decref behavior in shared
contexts. This change aligns Go with other managed bindings by enabling
concurrent decref support at context creation time.

- **Context initialization**
  - Call `Z3_enable_concurrent_dec_ref` in both Go context constructors:
    - `NewContext()`
    - `NewContextWithConfig(cfg *Config)`
- This ensures AST/object finalizer decrefs are handled under Z3’s
concurrent dec-ref mode.

- **Go binding docs**
- Updated Go README memory-management section to explicitly document
that contexts enable concurrent dec-ref for finalizer-driven decref
paths.

- **Focused regression coverage**
- Added a small Go test (`z3_context_test.go`) that exercises
`NewContext` through a basic SAT flow, ensuring context construction and
normal solver usage remain consistent.

```go
func NewContext() *Context {
    ctx := &Context{ptr: C.Z3_mk_context_rc(C.Z3_mk_config())}
    C.Z3_enable_concurrent_dec_ref(ctx.ptr)
    runtime.SetFinalizer(ctx, func(c *Context) {
        C.Z3_del_context(c.ptr)
    })
    return ctx
}
```

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-06-29 13:14:41 -06:00
..
c++ Fixes necessary to compile z3 included in clang-tidy via FetchContents. (#9768) 2026-06-08 19:44:01 -07:00
dll
dotnet dotnet: force PlatformTarget=AnyCPU to fix arm64 host load failure (#9868) 2026-06-16 09:52:04 -06:00
go Go bindings: enable concurrent dec_ref for GC-driven finalizers (#10002) 2026-06-29 13:14:41 -06:00
java fix build warnings 2026-06-22 18:20:23 -07:00
js Bump markdown-it from 14.1.0 to 14.2.0 in /src/api/js (#9881) 2026-06-16 11:34:20 -06:00
julia fix issues 1-10: add missing API bindings across Go, Julia, TypeScript, OCaml, and Java (#9432) 2026-05-04 09:29:47 -07:00
mcp
ml Expose Seq.mk_re_diff in ocaml bindings (#9584) 2026-05-21 10:29:08 -07:00
python Fix Pyodide build job failure by restoring wasm side-module linking (#9916) 2026-06-20 18:15:32 -06:00
api_algebraic.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
api_arith.cpp Add check that argument of Z3_is_algebraic_number is_expr (#8027) 2026-02-18 20:55:56 -08:00
api_array.cpp Fix API bugs exercised by test/deep_api_bugs.cpp 2026-03-12 22:58:53 +00:00
api_ast.cpp [code-simplifier] Simplify api_ast.cpp by removing unreachable branch and stray comment (#9570) 2026-05-19 13:56:17 -07:00
api_ast_map.cpp Add [[nodiscard]] to AST factory functions and modernize iterator loops (#8143) 2026-02-18 20:57:08 -08:00
api_ast_map.h
api_ast_vector.cpp Modern C++: Add std::span overload for mk_or, adopt std::clamp, optimize stream output (#8507) 2026-02-18 20:58:05 -08:00
api_ast_vector.h
api_bv.cpp
api_config_params.cpp
api_context.cpp Refactor mk_and and mk_app to use std::span API (#8285) 2026-02-18 20:57:52 -08:00
api_context.h
api_datalog.cpp Adopt std::optional for try_get_value and try_get_size functions (#8268) 2026-02-18 20:57:50 -08:00
api_datalog.h
api_datatype.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
api_finite_set.cpp add parameter validation 2026-02-19 14:02:59 -08:00
api_fpa.cpp Fix API bugs exercised by test/deep_api_bugs.cpp 2026-03-12 22:58:53 +00:00
api_goal.cpp
api_goal.h
api_log.cpp
api_model.cpp Fix indentation: use spaces instead of tabs in api_model.cpp CHECK_NON_NULL 2026-03-12 23:00:07 +00:00
api_model.h
api_numeral.cpp
api_opt.cpp Fix API bugs exercised by test/deep_api_bugs.cpp 2026-03-12 22:58:53 +00:00
api_params.cpp Modern C++: Add std::span overload for mk_or, adopt std::clamp, optimize stream output (#8507) 2026-02-18 20:58:05 -08:00
api_parsers.cpp
api_pb.cpp
api_polynomial.cpp preserve the initial state of the solver with push/pop for multiple objectives (#8264) 2026-02-18 20:57:53 -08:00
api_polynomial.h
api_qe.cpp
api_quant.cpp Fix API bugs exercised by test/deep_api_bugs.cpp 2026-03-12 22:58:53 +00:00
api_rcf.cpp Standardize for-loop increments to prefix form (++i) (#8199) 2026-02-18 20:57:29 -08:00
api_seq.cpp Fix API bugs exercised by test/deep_api_bugs.cpp 2026-03-12 22:58:53 +00:00
api_solver.cpp Fix API bugs exercised by test/deep_api_bugs.cpp 2026-03-12 22:58:53 +00:00
api_solver.h
api_special_relations.cpp
api_stats.cpp
api_stats.h
api_tactic.cpp Revert "Refactor find_tactic_cmd to use std::optional<tactic_cmd*> (#8331)" 2026-02-18 20:57:56 -08:00
api_tactic.h
api_util.h
CMakeLists.txt Fixes necessary to compile z3 included in clang-tidy via FetchContents. (#9768) 2026-06-08 19:44:01 -07:00
z3.h
z3_algebraic.h
z3_api.h Fix documentation for Z3_solver_to_dimacs_string (#9053) 2026-03-20 10:18:13 -07:00
z3_ast_containers.h
z3_fixedpoint.h
z3_fpa.h Return sign from Z3_fpa_get_numeral_sign as bool instead of int (#8047) 2026-02-18 20:56:01 -08:00
z3_logger.h
z3_macros.h
z3_optimization.h Implement Z3_optimize_translate for context translation (#8072) 2026-02-18 20:56:58 -08:00
z3_polynomial.h
z3_private.h
z3_rcf.h Return bool instead of int from Z3_rcf_interval (#8046) 2026-02-18 20:56:01 -08:00
z3_replayer.cpp Fix clang warnings about casting away const. (#9933) 2026-06-23 19:57:46 -06:00
z3_replayer.h Return sign from Z3_fpa_get_numeral_sign as bool instead of int (#8047) 2026-02-18 20:56:01 -08:00
z3_spacer.h
z3_v1.h