[Lldb-commits] [PATCH] D146590: [lldb] Update some uses of Python2 API in typemaps.

Jorge Gorbe Moya via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 24 11:45:00 PDT 2023


jgorbe added a comment.

I found the actual reason for the crash I was talking about. This patch only addressed the incorrect `OverflowError`, but the crash comes from a double free (as @rupprecht mentioned) in the error handling logic. The error path here <https://github.com/llvm/llvm-project/blob/main/lldb/bindings/python/python-typemaps.swig#L298> does both `free($1);` and `SWIG_fail;`. The same goes for another error check a few lines below that. In the generated code, the `SWIG_fail` macro is expanded to `goto fail` and the `fail` label also frees the same memory buffer.

I believe (but I don't have any experience with SWIG typemaps so this is an educated guess) that the call to `free` in the error path comes from the `%typemap(freearg)` immediately after that one. So if freearg already takes care of it, the error handling logic in `%typemap(in)` should just call `SWIG_fail`. Does that sound correct?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146590/new/

https://reviews.llvm.org/D146590



More information about the lldb-commits mailing list