# Unable to load DSO's when using embed sapi module

- Thread: https://externals.io/message/23626
- Original archive: https://news-web.php.net/php.internals/23626
- Started by Nabeel on 2006-05-24T09:58:54+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #23626 — Nabeel — 2006-05-24T09:58:54+00:00

URL: https://externals.io/message/23626#23626

Hi,

    I want to call PHP code from C. So, I compiled sapi/embed module 
with my PHP 5.1.4 source (--enable-embed=static). It works fine when I 
access standard PHP functions.  When any .so file  (e.g.: axis2.so) is 
dynamically loaded to PHP, it  gives the following error when I run my 
test C code. (this happens with other DSO's as well.)

PHP Warning:  PHP Startup: Unable to load dynamic library 
'/usr/local/lib/php/ext/axis2.so' - /usr/local/lib/php/ext/axis2.so: 
undefined symbol: _zval_ptr_dtor in Unknown on line 0

axis2.so  works fine thourgh cli and apache interfaces. I wonder whether 
I am missing something. Any help is greatly appreciated.

Thanks,
-Nabeel

---

## #23645 — Nabeel — 2006-05-25T10:47:12+00:00

URL: https://externals.io/message/23626#23645

Thanks for the guess. But when one of these parameters is wrong, PHP 
engine specifically says so. My configuratin options for php build are  
--with-apxs2=/usr/local/apache2/bin/apxs --enable-embed=static 
--with-zlib --enable-debug. I use phpize with the extension. So, this 
automatically makes the version, debug info, zts settings info of the 
extension exactly similar to those of PHP. I have listed the gdb trace 
for successful and unsuccessful cases. I'd appreciate if someone can 
point what the root cause for this issue.

===========================================================================
When I run a php file through CLI the gdb trace I get is listed below. 
It successfully loads the axis2.so

Breakpoint 1, php_ini_register_extensions () at 
/usr/app/php-5.1.4/main/php_ini.c:552
552             zend_llist_apply(&extension_lists.engine, 
php_load_zend_extension_cb TSRMLS_CC);
(gdb) n
553             zend_llist_apply(&extension_lists.functions, 
php_load_function_extension_cb TSRMLS_CC);
(gdb) s
zend_llist_apply (l=0x837ab9c, func=0x820e5d1 
<php_load_function_extension_cb>) at 
/usr/app/php-5.1.4/Zend/zend_llist.c:190
190             for (element=l->head; element; element=element->next) {
(gdb) n
191                     func(element->data TSRMLS_CC);
(gdb) s
php_load_function_extension_cb (arg=0x97a7650) at 
/usr/app/php-5.1.4/main/php_ini.c:232
232             zval *extension = (zval *) arg;
(gdb) n
235             php_dl(extension, MODULE_PERSISTENT, &zval, 0 TSRMLS_CC);
(gdb) p *extension
$4 = {value = {lval = 159003284, dval = 1.7054524387922518e-313, str = 
{val = 0x97a3294 "axis2.so", len = 8},
    ht = 0x97a3294, obj = {handle = 159003284, handlers = 0x8}}, 
refcount = 0, type = 6 '\006', is_ref = 243 '
(gdb) n
236     }
(gdb) n
zend_llist_apply (l=0x837ab9c, func=0x820e5d1 
<php_load_function_extension_cb>) at 
/usr/app/php-5.1.4/Zend/zend_llist.c:190
190             for (element=l->head; element; element=element->next) {
(gdb)
193     }
(gdb)
php_ini_register_extensions () at /usr/app/php-5.1.4/main/php_ini.c:555
555             zend_llist_destroy(&extension_lists.engine);
(gdb)

=================================================================================
When I use the embed sapi, it fails without being able to load axis2.so 
(please see the gdb trace below)

Breakpoint 1, php_ini_register_extensions () at 
/usr/app/php-5.1.4/main/php_ini.c:552
552             zend_llist_apply(&extension_lists.engine, 
php_load_zend_extension_cb TSRMLS_CC);
(gdb) n
553             zend_llist_apply(&extension_lists.functions, 
php_load_function_extension_cb TSRMLS_CC);
(gdb) s
zend_llist_apply (l=0x8344f5c, func=0x80d6f2d 
<php_load_function_extension_cb>) at 
/usr/app/php-5.1.4/Zend/zend_llist.c:190
190             for (element=l->head; element; element=element->next) {
(gdb) n
191                     func(element->data TSRMLS_CC);
(gdb) s
php_load_function_extension_cb (arg=0x920e580) at 
/usr/app/php-5.1.4/main/php_ini.c:232
232             zval *extension = (zval *) arg;
(gdb) n
235             php_dl(extension, MODULE_PERSISTENT, &zval, 0 TSRMLS_CC);
(gdb) p *extension
$3 = {value = {lval = 153133716, dval = 1.7051624436017789e-313, str = 
{val = 0x920a294 "axis2.so", len = 8},
    ht = 0x920a294, obj = {handle = 153133716, handlers = 0x8}}, 
refcount = 0, type = 6 '\006', is_ref = 61 '='}
(gdb) s
php_dl (file=0x920e580, type=1, return_value=0xbf943d74, start_now=0) at 
/usr/app/php-5.1.4/ext/standard/dl.c:113
113             if (type == MODULE_PERSISTENT) {
(gdb) n
114                     extension_dir = INI_STR("extension_dir");
(gdb)
119             if (type == MODULE_TEMPORARY) {
(gdb)
122                     error_type = E_CORE_WARNING;
(gdb)
125             if (extension_dir && extension_dir[0]){
(gdb)
126                     int extension_dir_len = strlen(extension_dir);
(gdb)
128                     libpath = 
emalloc(extension_dir_len+Z_STRLEN_P(file)+2);
(gdb)
130                     if (IS_SLASH(extension_dir[extension_dir_len-1])) {
(gdb)
133                             sprintf(libpath, "%s%c%s", 
extension_dir, DEFAULT_SLASH, Z_STRVAL_P(file)); /* SAFE */
(gdb)
125             if (extension_dir && extension_dir[0]){
(gdb) p libpath
$4 = 0x923bd04 "/usr/local/lib/php/ext/axis2.so"
(gdb) n
140             handle = DL_LOAD(libpath);
(gdb) s
141             if (!handle) {
(gdb) n
142                     php_error_docref(NULL TSRMLS_CC, error_type, 
"Unable to load dynamic library '%s' - %s", libpath, GET_DL_ERROR());

thanks,
-Nabeel

Richard Lynch wrote:

>Wild Guess:
>
>You maybe have different versions and/or different debug/zts settings
>on the binaries, and need to re-compile the other files in parallel...
>
>
>  
>
> > […]
