[all-commits] [llvm/llvm-project] 6a4f66: [MLIR][Python] restore `liveModuleMap` (#158506)

Maksim Levental via All-commits all-commits at lists.llvm.org
Sun Sep 14 21:45:52 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6a4f66476ff59a32898891345bc07547e71028ec
      https://github.com/llvm/llvm-project/commit/6a4f66476ff59a32898891345bc07547e71028ec
  Author: Maksim Levental <maksim.levental at gmail.com>
  Date:   2025-09-15 (Mon, 15 Sep 2025)

  Changed paths:
    M mlir/lib/Bindings/Python/IRCore.cpp
    M mlir/lib/Bindings/Python/IRModule.h
    M mlir/test/python/ir/module.py

  Log Message:
  -----------
  [MLIR][Python] restore `liveModuleMap` (#158506)

There are cases where the same module can have multiple references (via
`PyModule::forModule` via `PyModule::createFromCapsule`) and thus when
`PyModule`s get gc'd `mlirModuleDestroy` can get called multiple times
for the same actual underlying `mlir::Module` (i.e., double free). So we
do actually need a "liveness map" for modules.

Note, if `type_caster<MlirModule>::from_cpp` weren't a thing we could guarantree
this never happened except explicitly when users called `PyModule::createFromCapsule`.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list