Skip to content

[Bug] Segfault when instantiating abstract SearchStrategy() in TuneContext #18268

@tinywisdom

Description

@tinywisdom

Expected behavior

  • Instantiating TuneContext with a SearchStrategy should either:
    1. Provide a meaningful Python-side error (e.g., TypeError: cannot instantiate abstract class), or
    2. Require a concrete subclass to be used.

In either case, it should not crash with a segmentation fault.

Actual behavior

  • Directly calling SearchStrategy() segfaults via FFI into C++ when used in TuneContext.
  • Python receives no exception, only a hard crash.

Environment

  • OS: (Ubuntu 22.04.4 LTS (x86_64))
  • TVM version: (release v0.21.0)
  • Python: (3.10.16)
  • LLVM: (17.0.6)

Steps to reproduce

import tvm
from tvm.target import Target
from tvm.meta_schedule import TuneContext, SearchStrategy
from tvm.script import ir as I, relax as R

# A minimal Relax IRModule (identity)
@I.ir_module
class M:
    @R.function
    def main(x: R.Tensor((1,), "float32")) -> R.Tensor((1,), "float32"):
        return x

# Abstract SearchStrategy() => FFI into C++ => segfault in some versions
ctx = TuneContext(
    mod=M,
    target=Target("llvm"),
    search_strategy=SearchStrategy(),  # ❌ abstract class instantiation
)

# Typically segfaults here or later during ctx.tune()
print(ctx)

Error log

!!!!!!! TVM FFI encountered a Segfault !!!!!!!
  File "<unknown>", in __pyx_pw_3tvm_3ffi_4core_6Object_27__init_handle_by_constructor__(_object*, _object* const*, long, _object*)
  File "<unknown>", in __pyx_f_3tvm_3ffi_4core_FuncCall(void*, _object*, TVMFFIAny*, int*) [clone .constprop.0]
  File "<unknown>", in __pyx_f_3tvm_3ffi_4core_make_args(_object*, TVMFFIAny*, _object*)
  File "./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c", in 0x00007289e284251f
  File "<unknown>", in tvm::ffi::(anonymous namespace)::backtrace_handler(int)
  File "<unknown>", in tvm::ffi::(anonymous namespace)::Traceback()
Segmentation fault (core dumped)

Triage

  • needs-triage
  • bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triagePRs or issues that need to be investigated by maintainers to find the right assignees to address ittype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions