Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory has been released #36

Closed
zhaohainan666 opened this issue May 16, 2018 · 4 comments
Closed

Memory has been released #36

zhaohainan666 opened this issue May 16, 2018 · 4 comments

Comments

@zhaohainan666
Copy link

Py_DECREF(py_content);

py_content has been released in Py_DECREF(py_args)

@SashaAVCO
Copy link

Thank you.
Looks like this bug related to #31
, so if additionally to described there changes I comment this line of code
//Py_DECREF(py_args);
, then I don't need anymore moving free(content) to the middle of the func from the end of code block where it was before.
So looks like this double-free call sometimes destroyed something so next free(..) failed then.

@zhaohainan666
Copy link
Author

zhaohainan666 commented May 17, 2018

According to the Python documentation, PyTuple_SetItem steals a reference to the inserted object. So you shouldn't dereference py_content manually since py_args now owns py_content.

I think you should remove the Py_DECREF(py_content); line instead of the Py_DECREF(py_args); line.

@SashaAVCO
Copy link

Ok.
Just posted the resulted source code (that works Ok for me at least now both for simple example and for complex project with many-many *.python modules):

#31

@Falldog
Copy link
Owner

Falldog commented May 17, 2018

@zhaohainan666
excellent, thanks for your help, I didn't notice the PyTuple_SetItem will steal a reference.
I can't reproduce the issue. I will fix it and please help to check it in the latest code, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants