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

fix core dump when "new PyType" #30

Merged
merged 2 commits into from
Dec 26, 2023
Merged

fix core dump when "new PyType" #30

merged 2 commits into from
Dec 26, 2023

Conversation

he426100
Copy link
Contributor

复现代码

$type = new PyType;

修改前运行会coredump,修改后可以抛出异常

Fatal error: Uncaught Error: Call to private PyType::__construct() from global scope in /home/mrpzx/git/phpy/phpy-examples/test.php:3
Stack trace:
#0 {main}
  thrown in /home/mrpzx/git/phpy/phpy-examples/test.php on line 3

@he426100
Copy link
Contributor Author

ZEND_METHOD(PyType, __construct) {}

查了下,除了type还有iter也是这么写的,new PyIter也会coredump

@matyhtf
Copy link
Member

matyhtf commented Dec 26, 2023

应该将构造方法申明为私有,禁止 new PyDict/PyIter

Copy link
Member

@matyhtf matyhtf left a comment

Choose a reason for hiding this comment

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

stub 文件也需要提交上来。如果不禁止 new 的话,不光是 dtor 会 coredump,如果调用 $obj->__call 之类的方法也会 coredump

@matyhtf matyhtf merged commit 84f0b2d into swoole:main Dec 26, 2023
9 checks passed
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