Skip to content

ext/xml/expat_compat.h: add missing php.h include #3212

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

Closed
wants to merge 1 commit into from

Conversation

tpetazzoni
Copy link
Contributor

When expat support is disabled and libxml support is enabled, the
following part of the code in expat_compat.h gets used:

and therefore "php".h" is included. However, when libexpat support is
enabled, HAVE_LIBEXPAT is defined, and therefore the following part of
the code is used:

In this case, "php.h" is not included. Due to this, zend_alloc.h is
never included when building the ext/xmlrpc/libxmlrpc/xml_element.c
file, and therefore the estrdup -> _estrdup macros are never defined,
causing the following link time failure:

ext/xmlrpc/libxmlrpc/xml_element.o: In function xml_element_serialize': /home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:462: undefined reference to efree'
ext/xmlrpc/libxmlrpc/xml_element.o: In function xml_elem_entity_escape': /home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:347: undefined reference to emalloc'
ext/xmlrpc/libxmlrpc/xml_element.o: In function _xmlrpc_charHandler': /home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:646: undefined reference to efree'
ext/xmlrpc/libxmlrpc/xml_element.o: In function xml_elem_free_non_recurse': /home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:198: undefined reference to efree'
/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:199: undefined reference to efree' /home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:200: undefined reference to efree'
/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:207: undefined reference to efree' ext/xmlrpc/libxmlrpc/xml_element.o: In function xml_elem_new':
/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:263: undefined reference to ecalloc' ext/xmlrpc/libxmlrpc/xml_element.o: In function _xmlrpc_startElement':
/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:602: undefined reference to estrdup' /home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:607: undefined reference to emalloc'
/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:609: undefined reference to estrdup' /home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:610: undefined reference to estrdup'
ext/xmlrpc/libxmlrpc/xml_element.o: In function xml_elem_free_non_recurse': /home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:211: undefined reference to efree'
collect2: error: ld returned 1 exit status
make: *** [Makefile:248: sapi/cgi/php-cgi] Error 1

This link time failure can be produced with:

./configure --prefix=/usr --with-libdir=/usr/lib64 --disable-all
--without-pear --with-config-file-path=/etc --disable-phpdbg
--disable-cli --enable-cgi --disable-fpm --enable-xmlreader
--enable-xmlwriter --enable-libxml --enable-wddx --with-xmlrpc
--with-libexpat-dir=/

We fix it by including "php.h" in the HAVE_LIBEXPAT case.

Signed-off-by: Thomas Petazzoni [email protected]

When expat support is disabled and libxml support is enabled, the
following part of the code in expat_compat.h gets used:

and therefore "php".h" is included. However, when libexpat support is
enabled, HAVE_LIBEXPAT is defined, and therefore the following part of
the code is used:

In this case, "php.h" is not included. Due to this, zend_alloc.h is
never included when building the ext/xmlrpc/libxmlrpc/xml_element.c
file, and therefore the estrdup -> _estrdup macros are never defined,
causing the following link time failure:

ext/xmlrpc/libxmlrpc/xml_element.o: In function `xml_element_serialize':
/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:462: undefined reference to `efree'
ext/xmlrpc/libxmlrpc/xml_element.o: In function `xml_elem_entity_escape':
/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:347: undefined reference to `emalloc'
ext/xmlrpc/libxmlrpc/xml_element.o: In function `_xmlrpc_charHandler':
/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:646: undefined reference to `efree'
ext/xmlrpc/libxmlrpc/xml_element.o: In function `xml_elem_free_non_recurse':
/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:198: undefined reference to `efree'
/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:199: undefined reference to `efree'
/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:200: undefined reference to `efree'
/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:207: undefined reference to `efree'
ext/xmlrpc/libxmlrpc/xml_element.o: In function `xml_elem_new':
/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:263: undefined reference to `ecalloc'
ext/xmlrpc/libxmlrpc/xml_element.o: In function `_xmlrpc_startElement':
/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:602: undefined reference to `estrdup'
/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:607: undefined reference to `emalloc'
/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:609: undefined reference to `estrdup'
/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:610: undefined reference to `estrdup'
ext/xmlrpc/libxmlrpc/xml_element.o: In function `xml_elem_free_non_recurse':
/home/thomas/projets/php/ext/xmlrpc/libxmlrpc/xml_element.c:211: undefined reference to `efree'
collect2: error: ld returned 1 exit status
make: *** [Makefile:248: sapi/cgi/php-cgi] Error 1

This link time failure can be produced with:

./configure --prefix=/usr --with-libdir=/usr/lib64 --disable-all \
	    --without-pear --with-config-file-path=/etc --disable-phpdbg \
	    --disable-cli --enable-cgi --disable-fpm --enable-xmlreader \
	    --enable-xmlwriter --enable-libxml --enable-wddx --with-xmlrpc \
	    --with-libexpat-dir=/

We fix it by including "php.h" in the HAVE_LIBEXPAT case.

Signed-off-by: Thomas Petazzoni <[email protected]>
@cmb69
Copy link
Member

cmb69 commented Apr 9, 2018

Thanks for the PR!

On a cursory glance this looks like a bug, so would require a ticket in our bug tracker. And if it is indeed a bug, the fix should target the lowest actively supported PHP version (currently, PHP-7.1), which exhibits the erroneous behavior.

@krakjoe
Copy link
Member

krakjoe commented Sep 4, 2018

@tpetazzoni any action here ?

@tpetazzoni
Copy link
Contributor Author

@krakjoe so I need to fill an issue in the bug tracker first ?

@cmb69
Copy link
Member

cmb69 commented Sep 4, 2018

Yes, please file a bug report. The changelog will convert the bug number automatically to a link, so users can quickly check whether the bug may affect their code. Also, if the commit message contains the bug number, the bug will automatically be closed as soon as the PR is merged/applied.

@php-pulls
Copy link

Comment on behalf of cmb at php.net:

Thanks! Applied via 3691b6d.

@php-pulls php-pulls closed this Sep 15, 2018
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