Edit report at https://bugs.php.net/bug.php?id=77194&edit=1
ID: 77194
Updated by: ab@php.net
Reported by: svbussww at 126 dot com
Summary: php7ts.dll crashing when running embed
Status: Open
Type: Bug
Package: Reproducible crash
Operating System: Windows 7
PHP Version: 7.2.12
Block user comment: N
Private report: N
New Comment:
Thanks for the further info. Please realize, that you're not using the embed SAPI, but are
developing your own. To use embed SAPI, you should link with php7embed.lib and include
sapi/embed/php_embed.h. It is fine to develop a custom SAPI as you do, but in that case no bug
report against the embed SAPI should be filed.
The code you've posted looks OK at first glance. If you indeed were intended to use the embed
SAPI, please check a worky example here https://gist.github.com/paresy/3cbd4c6a469511ac7479aa0e7c42fea7,
linked from bug #74011. Unfortunately I don't come to debug your code in near days, so
can't tell yet whether it uncovers a bug in PHP.
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2018-11-23 22:49:36] svbussww at 126 dot com
Call API Step Accurate
in Main
tsrm_startup
sapi_startup
php_embed_startup(Internal call php_module_startup)
CreateThread(Loop call)
....
-------------
in Thread
ts_resource
...
ts_free_thread
-------------
The php_module_startup function determines that it is only called once in php_embed_startup
Test VC++ Code In http://jxcraft.net/Test.cpp
Suitable for PHP7.2.12,php7ts.dll Use officially compiled DLL
All remaining irrelevant code has been removed
------------------------------------------------------------------------
[2018-11-23 22:23:10] ab@php.net
Thanks for the further info. The embed SAPI has php_embed_startup(), which calls
php_module_startup(). If you call it separately, you might be calling it twice. Otherwise, it's
not clear to me, what exactly is NULL that it tries to dereference, in emalloc, in cwd_globals_ctor?
It would rock, if you could extract only the relevant piece of your code where embed is integrated
(just as one file with the corresponding embed only API calls), that one could review. It's
otherwise a bit hard to guess, as embed is something that gets integrated into another app and the
failures can be specific to that app.
Thanks.
------------------------------------------------------------------------
[2018-11-23 20:57:53] svbussww at 126 dot com
Stack
php7ts.dll!_emalloc(unsigned __int64 size) Line 2425
php7ts.dll!cwd_globals_ctor(_virtual_cwd_globals * cwd_g) Line 391
php7ts.dll!allocate_new_resource(_tsrm_tls_entry * * thread_resources_ptr, unsigned long thread_id)
è¡ 315
php7ts.dll!ts_resource_ex(int id, unsigned long * th_id) Line 395
Exception
The first chance exception at 0x000007FEE3C9F648 (php7ts.dll) (in Test.exe): 0xC0000005: An access
violation occurred while reading location 0x0000000000000000.
There is an unhandled exception at 0x000007FEE3C9F648 (php7ts.dll) (in Test.exe): 0xC0000005: An
access violation occurred while reading location 0x0000000000000000.
------------------------------------------------------------------------
[2018-11-23 19:52:45] svbussww at 126 dot com
This problem also exists in VC15
And the problem exists in 7.0.32 7.1.24 7.2.12 7.3.0RC5 In the version
After php_module_startup call
Calling ts_resource_ex in a newly started thread has a chance to crash
Will not crash if php_module_startup is not called
------------------------------------------------------------------------
[2018-11-23 15:38:47] ab@php.net
Thanks for the report. First, vc12 is not suitable, if you use 7.2 binaries from php.net. Please
compile your project with vc15 (vs2017) and post a backtrace. Depending on it, but likely,
we'll need some reproduce, too.
Thanks.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=77194
--
Edit this bug report at https://bugs.php.net/bug.php?id=77194&edit=1