[Mlir-commits] [mlir] 9816cc9 - Fix a memory leak in the Python implementation of bytecode writer

Jacques Pienaar llvmlistbot at llvm.org
Wed Jun 21 09:41:03 PDT 2023


Author: Adam Paszke
Date: 2023-06-21T09:40:51-07:00
New Revision: 9816cc916f56feae9c5273c0c0be1255a20952f5

URL: https://github.com/llvm/llvm-project/commit/9816cc916f56feae9c5273c0c0be1255a20952f5
DIFF: https://github.com/llvm/llvm-project/commit/9816cc916f56feae9c5273c0c0be1255a20952f5.diff

LOG: Fix a memory leak in the Python implementation of bytecode writer

The bytecode writer config was heap-allocated, but was never freed, causing ASAN errors.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D153440

Added: 
    

Modified: 
    mlir/lib/Bindings/Python/IRCore.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp
index facd33c727351..da8a58de775a3 100644
--- a/mlir/lib/Bindings/Python/IRCore.cpp
+++ b/mlir/lib/Bindings/Python/IRCore.cpp
@@ -1171,6 +1171,7 @@ void PyOperationBase::writeBytecode(const py::object &fileObject,
   mlirBytecodeWriterConfigDesiredEmitVersion(config, *bytecodeVersion);
   MlirLogicalResult res = mlirOperationWriteBytecodeWithConfig(
       operation, config, accum.getCallback(), accum.getUserData());
+  mlirBytecodeWriterConfigDestroy(config);
   if (mlirLogicalResultIsFailure(res))
     throw py::value_error((Twine("Unable to honor desired bytecode version ") +
                            Twine(*bytecodeVersion))


        


More information about the Mlir-commits mailing list