Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ tvm_option(COMPILER_RT_PATH "Path to COMPILER-RT" "3rdparty/compiler-rt")
# Contrib library options
tvm_option(USE_BLAS "The blas library to be linked" none)
tvm_option(USE_AMX "Enable Intel AMX" OFF)
tvm_option(USE_Z3 "Build with Z3 SMT solver support" OFF)
tvm_option(USE_Z3 "Build with Z3 SMT solver support" AUTO)
tvm_option(USE_MKL "MKL root path when use MKL blas" OFF)
tvm_option(USE_DNNL "Enable DNNL codegen" OFF)
tvm_option(USE_CUDNN "Build with cuDNN" OFF)
Expand Down
2 changes: 1 addition & 1 deletion ci/jenkins/docker-images.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# This data file is read during when Jenkins runs job to determine docker images.
[jenkins]
ci_tag: 20260619-214849-4174cdf5
ci_tag: 20260629-192919-24bbfd2e
ci_arm: tlcpack/ci-arm:%(ci_tag)s
ci_cpu: tlcpack/ci-cpu:%(ci_tag)s
ci_gpu: tlcpack/ci-gpu:%(ci_tag)s
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

[build-system]
# z3-static ships the PIC static libz3 + headers for explicit USE_Z3=ON builds.
# z3-static ships the PIC static libz3 + headers consumed by USE_Z3=ON.
requires = [
"scikit-build-core>=0.11",
"setuptools-scm>=8",
Expand Down Expand Up @@ -146,8 +146,8 @@ logging.level = "INFO"
[tool.scikit-build.cmake.define]
TVM_BUILD_PYTHON_MODULE = "ON"
USE_CUDA = "OFF"
# Keep Z3 disabled by default until CI's C++ toolchain can link z3-static reliably.
USE_Z3 = "OFF"
# Statically link Z3 from the z3-static build dependency by default.
USE_Z3 = "AUTO"
BUILD_TESTING = "OFF"

[tool.setuptools_scm]
Expand Down
4 changes: 2 additions & 2 deletions src/arith/z3_prover.cc
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,8 @@ class Z3Prover::Impl : ExprFunctor<z3::expr(const PrimExpr&)> {
/// @brief Check if the expression type is supported by z3 integer operations.
static bool IsZ3SupportedExpr(const PrimExprNode* expr) {
TVM_FFI_DCHECK(expr != nullptr);
TVM_FFI_DCHECK(expr->ty.defined());
const auto* prim_ty = expr->ty.as<PrimTypeNode>();
TVM_FFI_DCHECK(expr->ty().defined());
const auto* prim_ty = expr->ty().as<PrimTypeNode>();
Comment on lines +559 to +560

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Calling expr->ty() returns a temporary Type (or PrimType) object by value. Calling .as<PrimTypeNode>() directly on this temporary returns a raw pointer (const PrimTypeNode*) to the underlying node, but the temporary Type object itself is destroyed at the end of the statement (the semicolon).

If the PrimExprNode does not hold a strong reference to this specific PrimTypeNode instance (e.g., if ty() constructs the PrimType on the fly, which is common in TVM), the reference count of the PrimTypeNode drops to 0 and it is deallocated immediately. This leaves prim_ty as a dangling pointer, leading to a Use-After-Free (UAF) bug when prim_ty is accessed on the subsequent lines.

To fix this, store the returned Type object in a local variable to keep it alive for the duration of the function.

    auto ty = expr->ty();
    TVM_FFI_DCHECK(ty.defined());
    const auto* prim_ty = ty.as<PrimTypeNode>();

TVM_FFI_DCHECK(prim_ty != nullptr);
return (prim_ty->dtype.code == static_cast<uint8_t>(DLDataTypeCode::kDLInt) ||
prim_ty->dtype.code == static_cast<uint8_t>(DLDataTypeCode::kDLUInt) ||
Expand Down
Loading