php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74711 wrong libraries linked to SAPI
Submitted: 2017-06-08 14:05 UTC Modified: -
From: martijn at openbsd dot org Assigned:
Status: Open Package: Dynamic loading
PHP Version: Irrelevant OS: OpenBSD (probably irrelevant)
Private report: No CVE-ID:
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: martijn at openbsd dot org
New email:
PHP Version: OS:

 

 [2017-06-08 14:05 UTC] martijn at openbsd dot org
Description:
------------
When building PHP with shared modules I found that php wouldn't startup any more when removing one of the modules and dependencies of the system (in this case ext/odbc).

This is because libiodbc is linked into the different SAPIs:
$ ldd ./php
./php:
        Start            End              Type Open Ref GrpRef Name
        00000a9e0f800000 00000a9e0ff02000 exe  2    0   0      ./php
        00000aa0c76d5000 00000aa0c7927000 rlib 0    1   0      /usr/local/lib/libiodbc.so.3.16
        00000aa0f976d000 00000aa0f997b000 rlib 0    4   0      /usr/lib/libpthread.so.23.0
        00000aa102095000 00000aa1023ab000 rlib 0    1   0      /usr/lib/libstdc++.so.57.0
        00000aa087c66000 00000aa087e8d000 rlib 0    3   0      /usr/lib/libm.so.10.0
        00000aa0e1e2e000 00000aa0e2044000 rlib 0    2   0      /usr/lib/libz.so.5.0
        00000aa03e983000 00000aa03ebc7000 rlib 0    1   0      /usr/local/lib/libpcre.so.3.0
        00000aa06c91f000 00000aa06cc81000 rlib 0    1   0      /usr/local/lib/libxml2.so.15.2
        00000aa0458a5000 00000aa045aca000 rlib 0    2   0      /usr/local/lib/liblzma.so.2.1
        00000aa089fd8000 00000aa08a2d7000 rlib 0    2   0      /usr/local/lib/libiconv.so.6.0
        00000aa0ec06b000 00000aa0ec2bd000 rlib 0    1   0      /usr/lib/libssl.so.43.3
        00000aa0fbff1000 00000aa0fc3bb000 rlib 0    2   0      /usr/lib/libcrypto.so.41.2
        00000aa0b473e000 00000aa0b4a0b000 rlib 0    1   0      /usr/lib/libc.so.89.5
        00000aa085600000 00000aa085600000 rtld 0    1   0      /usr/libexec/ld.so

I traced the problem via Makefile target BUILD_CLI which include EXTRA_LIBS, which has this extra library added.

When looking around in the configure file I found that EXTRA_LIBS is a concatenation of $EXTRA_LIBS $DLIBS $LIBS.
Adding some debugging found me that LIBS is the culprit in this case.

Continuing my search I found that LIBS is used in quite a few places throughout the m4 files and that most of the time they save the value in a tempvar and restore it later, but I did find that the PHP_ADD_LIBRARY macro in aclocal.m4 and acinclude.m4 contains LIBS as the 5th argument. This in my opinion is the most likely cause for not unsetting LIBS.

I tried to change the name LIBS to BLAHLIBS, but that breaks the libxml checks.

Issue found in php 5.6.30, 7.0.19 and 7.1.5

Test script:
---------------
./configure --disable-rpath --disable-static --enable-inline-optimization --enable-shared --program-suffix=-7.1 --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php-7.1 --with-pear=/usr/local/share/php-7.1 --with-pic --enable-filter --enable-hash --enable-libxml=/usr/local --enable-session --with-mhash=/usr/local --with-openssl --with-pcre-regex=/usr/local --with-zlib --with-apxs2=/usr/local/sbin/apxs2 --enable-cgi --enable-cli --disable-phpdbg --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-bcmath=shared --with-bz2=shared,/usr/local --enable-calendar=shared --enable-ctype=shared --with-curl=shared,/usr/local --enable-dba=shared --with-gdbm=/usr/local --enable-dom=shared --with-enchant=shared --enable-exif=shared --enable-fileinfo=shared --enable-ftp=shared --with-gd=shared --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-zlib-dir=/usr --with-freetype-dir=/usr/X11R6 --with-xpm-dir=/usr/X11R6 --with-gettext=shared,/usr/local --with-gmp=shared,/usr/local --with-iconv=shared,/usr/local --with-imap=shared,/usr/local --with-imap-ssl --enable-intl=shared --with-icu-dir=/usr/local --enable-json=shared --with-ldap=shared,/usr/local --with-ldap-sasl=/usr/local --enable-mbstring=shared --with-onig=/usr/local --with-mcrypt=shared,/usr/local --enable-mysqlnd=shared --with-mysqli=shared,mysqlnd --with-iodbc=shared,/usr/local --enable-opcache --enable-pcntl=shared --enable-pdo=shared --with-pdo-dblib=shared,/usr/local --with-pdo-mysql=shared,mysqlnd --with-pdo-pgsql=shared,/usr/local --with-pdo-sqlite=shared,/usr/local --with-pgsql=shared,/usr/local --enable-phar=shared --enable-posix=shared --with-pspell=shared,/usr/local --with-readline=shared --enable-shmop=shared,/usr/local --enable-simplexml=shared --with-snmp=shared,/usr/local --enable-soap=shared,/usr/local --enable-sockets=shared --with-sqlite3=shared,/usr/local --enable-sysvmsg=shared --enable-sysvsem=shared --enable-sysvshm=shared --with-tidy=shared,/usr/local --enable-tokenizer=shared --enable-wddx=shared --enable-xml=shared --enable-xmlreader=shared --with-xmlrpc=shared --enable-xmlwriter=shared --with-xsl=shared --enable-zip=shared,/usr/local --prefix=/usr/local --sysconfdir=/etc --mandir=/usr/local/man --infodir=/usr/local/info --localstatedir=/var --disable-silent-rules --disable-gtk-doc CFLAGS=-O2 -pipe -I/usr/local/include -pthread YACC=/usr/bin/yacc

make

ldd sapi/cli/php


Patches

patch-ext_odbc_config_m4.diff (last revision 2017-07-05 09:48 UTC) by martijn at openbsd dot org)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-06-08 14:31 UTC] spam2 at rhsoft dot net
"When building PHP with shared modules I found that php wouldn't startup any more when removing one of the modules and dependencies of the system" - how is that a bug? when you remove sharde libraries software is linked to you break that software

hence package managers was invited and when you try to remove such dependencies when you built PHP as package it would suggest to remove PHP or just say "No"
 [2017-07-05 09:52 UTC] martijn at openbsd dot org
Well, the point is, this is for a revamp of the OpenBSD package(s). So your point is kind of mute...

ODBC is in no way related to the PHP core and should not be linked to it.

The attached patch is based on php7.1.6, but works equally well on 5.6 and 7.0 and fixes the issue for me.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC