Skip to content

fix bug about deallocating None#33723

Merged
wanghuancoder merged 3 commits intoPaddlePaddle:developfrom
wanghuancoder:fix_pythoncapi_none
Jun 23, 2021
Merged

fix bug about deallocating None#33723
wanghuancoder merged 3 commits intoPaddlePaddle:developfrom
wanghuancoder:fix_pythoncapi_none

Conversation

@wanghuancoder
Copy link
Contributor

@wanghuancoder wanghuancoder commented Jun 22, 2021

PR types

Bug fixes

PR changes

Others

Describe

PR #32524 merge后导致分布式CE崩溃。并报如下错误:
Fatal Python error: deallocating None
经分析,应该在return Py_None;前加Py_INCREF(Py_None);。否则导致Py_None的引用计数错误。

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Contributor

@zhiqiu zhiqiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +491 to +497
return_str = "Py_INCREF(Py_None);\n return Py_None;";
} else if (outs_num == 1) {
return_str = "MakeReturnPyObject(" + return_str + ")";
return_str = "return MakeReturnPyObject(" + return_str + ");";
} else {
return_str = "MakeReturnPyObject(" +
return_str = "return MakeReturnPyObject(" +
paddle::string::Sprintf(RETURN_TUPLE_TEMPLATE, return_str) +
")";
");";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better use some string templates

@wanghuancoder wanghuancoder merged commit aa1aac9 into PaddlePaddle:develop Jun 23, 2021
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

Successfully merging this pull request may close these issues.

2 participants