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

Update zend_execute_API.c #5911

Closed
wants to merge 3 commits into from
Closed

Update zend_execute_API.c #5911

wants to merge 3 commits into from

Conversation

GXhua
Copy link

@GXhua GXhua commented Jul 30, 2020

in some case , these is no opline in execute_data ,such like this:
memset(&fake_execute_data, 0, sizeof(fake_execute_data));

in some case , these is no opline in execute_data ,such like this:
 memset(&fake_execute_data, 0, sizeof(fake_execute_data));
@nikic
Copy link
Member

nikic commented Jul 30, 2020

Do you have a test case where this occurs?

@GXhua
Copy link
Author

GXhua commented Jul 31, 2020

well,Im trying to make a memory analysis tool for PHP, which will intercept emalloc and when it working with opcache, core dump occurs,bt like this:
(gdb) bt
#0 0x00000000009e199d in zend_get_executed_lineno () at /phpsrc/php-7.3.8/Zend/zend_execute_API.c:489
#2 tracker_malloc (size=) at /src/swoole-tracker/apm_mem.c:1709
#3 0x00000000009b944a in _emalloc (size=96) at /phpsrc/php-7.3.8/Zend/zend_alloc.c:2496
#4 0x00000000009c0d9d in zend_string_alloc (persistent=0, len=64) at Zend/zend_string.h:133
#5 zend_mangle_property_name (src1=0x120f980 "COMPILER_HALT_OFFSET", src1_length=24, src2=0x7fc244905ed8 "xxxxx/Utils/Context.php", src2_length=38, internal=0) at /phpsrc/php-7.3.8/Zend/zend_compile.c:1305
#6 0x00000000009de5b5 in zend_get_special_constant (name=0x7fc243efa8cc "COMPILER_HALT_OFFSET", name_len=24) at /phpsrc/php-7.3.8/Zend/zend_constants.c:223
#7 0x00000000009de8b3 in zend_get_constant_str_impl (name=0x7fc243efa8cc "COMPILER_HALT_OFFSET", name_len=24) at /phpsrc/php-7.3.8/Zend/zend_constants.c:259
#8 0x00000000009de8ff in zend_get_constant_str (name=0x7fc243efa8cc "COMPILER_HALT_OFFSET", name_len=24) at /phpsrc/php-7.3.8/Zend/zend_constants.c:269
#9 0x00007fc243e42bd8 in zend_persist_op_array_ex (op_array=0x7fc1f545f808, main_persistent_script=0x7fc1f545f800) at /phpsrc/php-7.3.8/ext/opcache/zend_persist.c:377
the f 9 will set EG(current_execute_data) to fake execute_data which has no opline.
but I think that normal PHP code cannot trigger this. I am not sure if there are other cases, but I think it is better to be protected in this way.

@morrisonlevi
Copy link
Contributor

morrisonlevi commented Sep 1, 2020

I think I've hit this sort of case in observers in the .begin handler if I zend_printf. In some cases it works (the zend_test extension tests this, not sure what's different yet).

@Girgias
Copy link
Member

Girgias commented Jan 4, 2023

Has this PR gone stale?

@github-actions
Copy link

github-actions bot commented Mar 6, 2023

There has not been any recent activity in this PR. It will automatically be closed in 7 days if no further action is taken.

@github-actions github-actions bot added the Stale label Mar 6, 2023
@github-actions github-actions bot closed this Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants