trexinc / evil-programmers

Misc. Far plugins and tools by evil programmers
66 stars 26 forks source link

It seems like `PyObject_GetAttr` returns a borrowed reference #52

Closed vladfolts closed 3 years ago

alabuzhev commented 3 years ago

Huh?

PyObject_GetAttr Return value: New reference.

vladfolts commented 3 years ago

Return value: New reference.

Thanks for the link. It was not specified explicitly in the document that I googled. Still the problem is somewhere in between: PyObject_GetAttr -> py::list -> iterator -> PyObject* that becomes invalid while py::list with this element is still alive... Considering that this extra reference inc in the change helps it looks like py::list is GC'ed somehow...

vladfolts commented 3 years ago

OK, so the problem is in py::list not being actually alive... And that is because of Far callingGetFilesW with elements from GetFindDataW call after it already called FreeFindDataW... I guess I don't have any choice other than to use a custom FARPANELITEMFREECALLBACK...

I'm closing this PR.

alabuzhev commented 3 years ago

OK, so the problem is in py::list not being actually alive... And that is because of Far callingGetFilesW with elements from GetFindDataW call after it already called FreeFindDataW

Do you have an example? I've faced something similar recently in a different context, it might be an overlook in Far worth fixing.

vladfolts commented 3 years ago

I'll prepare an updated "Hello World" and make a new PR.