php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74149 SAPI application linking to PHP static library can't call zend_signal_startup()
Submitted: 2017-02-22 15:12 UTC Modified: -
From: sathya at laufers dot net Assigned:
Status: Closed Package: Compile Failure
PHP Version: 7.1.2 OS: GNU/Linux
Private report: No CVE-ID: None
 [2017-02-22 15:12 UTC] sathya at laufers dot net
Description:
------------
A C++ SAPI application linking to PHP 7.1 compiled as static embedded SAPI library can't compile as the mandatory function "zend_signal_startup()" is not wrapped in 'extern "C" {' and therefore not accessible. This is the same issue as in "Bug #71041". I'm creating a new bug report, because Zend signals are now enabled by default and even with disabling them using "--disable-zend-signals" it doesn't work (see "additional remark"). 

Regarding the comment in the other bug report:

> The only place that this function should be called is in the SAPI layer, since all usable SAPI's are distributed with PHP, there doesn't seem to be a legitimate need to export the symbol.

I don't agree. Most people using the static embedded library to integrate PHP into their programs will stumble upon this problem.

Additional remark:

Using the configure option "--disable-zend-signals" the program compiles but crashes with signal 6 as "zend_signal_activate()" is still being called by "php_request_startup()" - but with uninitialized variables:

#0  0x00007f25f672f428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007f25f673102a in __GI_abort () at abort.c:89
#2  0x000000000044cb21 in Debug::safe_abort () at DeathHandler.cpp:387
#3  Debug::DeathHandler::HandleSignal (sig=<optimized out>, secret=0x7f25ef19c100) at DeathHandler.cpp:573
#4  <signal handler called>
#5  0x000000000069c717 in memcpy (__len=1040, __src=0x12f2720 <global_orig_handlers>, __dest=<optimized out>) at /usr/include/x86_64-linux-gnu/bits/string3.h:53
#6  zend_signal_activate () at /usr/src/user/php-7.1.2/Zend/zend_signal.c:313
#7  0x000000000060309f in php_request_startup () at /usr/src/user/php-7.1.2/main/main.c:1640


Test script:
---------------
<?php
//Not applicable
?>

Expected result:
----------------
Successful linking of PHP 7.1 static embedded library.

Actual result:
--------------
Error during linking:

libscriptengine.a(libscriptengine_a-php_sapi.o): In function `php_xxx_init()':
xxx/php_sapi.cpp:1787: undefined reference to `zend_signal_startup()'
collect2: error: ld returned 1 exit status
make[2]: *** [xxx] Fehler 1
Makefile:635: die Regel für Ziel „xxx“ scheiterte
make[1]: *** [all-recursive] Fehler 1
make: *** [all] Fehler 2

Patches

php-7.1.2-external-SAPI-fix.patch (last revision 2017-02-22 15:15 UTC by sathya at laufers dot net)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-09 07:44 UTC] krakjoe@php.net
Automatic comment on behalf of krakjoe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8599ce4f18758d4aeff494366d884d4bb7dac2a2
Log: Fix bug #74149 static embed SAPI linkage error
 [2017-03-09 07:44 UTC] krakjoe@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC