Bug #73826 [Com]: Errors with running embeded php on OS X (resolved partially with hacks)
| From: | ejrx7753 at gmail dot com | Date: | Wed, 11 Jan 2017 13:59:37 +0000 |
| Subject: | Bug #73826 [Com]: Errors with running embeded php on OS X (resolved partially with hacks) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-206518@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73826&edit=1
ID: 73826
Comment by: ejrx7753 at gmail dot com
Reported by: ejrx7753 at gmail dot com
Summary: Errors with running embeded php on OS X (resolved
partially with hacks)
Status: Not a bug
Type: Bug
Package: Reproducible crash
Operating System: OS X 10.12
PHP Version: 7.1.0
Block user comment: N
Private report: N
New Comment:
Hi,
Did you test the embed SAPI on OS X? If so can you post the code that you used for those tests? I
know that this code works on Windows, for example, after porting, so it os OS-specific, and I would
be glad to get a link to better code to use as an example.
Previous Comments:
------------------------------------------------------------------------
[2017-01-11 05:34:50] krakjoe@php.net
The code you have linked too is not supported by PHP, or the authors (facebook).
Having tested the embed SAPI this morning in ZTS and non-zts, I can say with confidence there are no
problems in php-src, and any bugs you are experiencing are because of mistakes in your attempt to
port that old (PHP5) code.
Sorry, but there is nothing we can do to help you, other than to suggest that you use the embed SAPI
directly.
------------------------------------------------------------------------
[2016-12-28 04:22:37] ejrx7753 at gmail dot com
Description:
------------
I ported some code from (https://github.com/facebookarchive/phpembed) to PHP 7. At least the init
and function call parts. It works on Windows, but on OS X it crashes.
I have done a number of hacks that have gotten it to work on OS X, but am much confused about why it
works that way. Actually, on review, it does not offer the same functionality. So I need either a
proper init sequence for the embed module, or we have a crash. I can test any suggested updates and
put together a test script.
From (https://github.com/facebookarchive/phpembed/blob/master/src/php_cxx.cpp) basic sequence of
events:
----init_global_php----
#ifdef ZTS
// PHPE: if they want threads, let's give them more than 1!
tsrm_startup(128, 32, 0, NULL);
compiler_globals = (zend_compiler_globals *)ts_resource(compiler_globals_id);
executor_globals = (zend_executor_globals *)ts_resource(executor_globals_id);
core_globals = (php_core_globals *)ts_resource(core_globals_id);
sapi_globals = (sapi_globals_struct *)ts_resource(sapi_globals_id);
tsrm_ls = (void ***)ts_resource(0);
#endif
sapi_startup(&php_embed_module);
if (php_embed_module.startup(&php_embed_module)==FAILURE) {
return FAILURE;
}
zend_llist_init(&global_vars, sizeof(char *), NULL, 0);
///// Code fails with segmentation fault inside one of the ts_resource calls ////
//// Working Code on OS X ///////////
tsrm_startup(2, 32, 0, NULL);
int argc = 1;
char* text = copy_literal("embed4");
char *argv[2] = { text, NULL };
php_embed_init(argc, argv);
/////////////////////////////////////
This working code I pulled from someone's git repo, and it contained the comment "////What
is this? I pulled it from a textbook. Don't know what it does".
So this generates three questions
1. Should the code above that works on Windows work on Mac OS X?... If there is a bug.
2. What is the proper init sequence (if code #1 is a little big "off")?
3. Should there not be unit tests for php embed sapi? To what extent is debateable, but at least the
startup/function call/parse script/run script/shutdown aspects.
I can make a reproducable case for this bug, but want to verify #2 before doing so.
Test script:
---------------
Will post when verified proper usage and tested it.
Expected result:
----------------
working code, as on Windows
Actual result:
--------------
Segfault inside ts_resource somewhere, and various other places depending on how code is
commented/ordered.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73826&edit=1