#27104 [Fbk->Opn]: CLI SAPI module variable name conflict

From: Date: Sun, 01 Feb 2004 13:35:04 +0000
Subject: #27104 [Fbk->Opn]: CLI SAPI module variable name conflict
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-54254@lists.php.net to get a copy of this message
ID: 27104 User updated by: alex dot php at epathology dot com dot au Reported By: alex dot php at epathology dot com dot au -Status: Feedback +Status: Open Bug Type: CGI related Operating System: OpenBSD 3.3 PHP Version: 4CVS-2004-02-01 New Comment: $ gcc -v Reading specs from /usr/lib/gcc-lib/i386-unknown-openbsd3.3/2.95.3/specs gcc version 2.95.3 20010125 (prerelease, propolice) This is the default compiler that comes with OpenBSD 3.3. I just checked a draft copy of the ISO C99 specification, and it would seem that defining static optind and optarg variables after including unistd.h, which has extern declarations with the same name, results in undefined behaviour (6.2.2.7). So I guess the code violates standard C regardless of whether it works with some versions GCC. Previous Comments: ------------------------------------------------------------------------ [2004-02-01 05:53:47] sniper@php.net What gcc version? ------------------------------------------------------------------------ [2004-02-01 00:44:49] alex dot php at epathology dot com dot au The problem does occur with the snapshot, and with "./configure --disable-all --with-apxs". Perhaps I should add that there were also the following warnings, although I don't think they are related. For ext/standard/var_unserializer.c: /bin/sh /home/alex/src/test/php4-STABLE-200402010430/libtool --silent --preserve-dup-deps --mode=compile gcc - Iext/standard/ -I/home/alex/src/test/php4-STABLE-200402010430/ext/standard/ -DPHP_ATOM_INC -I/home/alex/src/tes t/php4-STABLE-200402010430/include -I/home/alex/src/test/php4-STABLE-200402010430/main -I/home/alex/src/test/ph p4-STABLE-200402010430 -I/home/alex/src/test/php4-STABLE-200402010430/Zend -I/home/alex/src/test/php4-STABLE-2 00402010430/TSRM -g -O2 -prefer-pic -c /home/alex/src/test/php4-STABLE-200402010430/ext/standard/var_unserial izer.c -o ext/standard/var_unserializer.lo /home/alex/src/test/php4-STABLE-200402010430/ext/standard/var_unserializer.c: In function `php_var_unserialize' : /home/alex/src/test/php4-STABLE-200402010430/ext/standard/var_unserializer.c:308: warning: comparison is always false due to limited range of data type For sapi/apache/sapi_apache.c, and similarly repeated for sapi/apache/mod_php4.c, and sapi/apache/php_apache.c: /bin/sh /home/alex/src/test/php4-STABLE-200402010430/libtool --silent --preserve-dup-deps --mode=compile gcc -DDEV_RANDOM=/de v/arandom -DMOD_SSL=208112 -DEAPI -DUSE_EXPAT -I/usr/lib/apache/include -Isapi/apache/ -I/home/alex/src/test/php4-STABLE-20040 2010430/sapi/apache/ -DPHP_ATOM_INC -I/home/alex/src/test/php4-STABLE-200402010430/include -I/home/alex/src/test/php4-STABLE-2 00402010430/main -I/home/alex/src/test/php4-STABLE-200402010430 -I/home/alex/src/test/php4-STABLE-200402010430/Zend -I/home/a lex/src/test/php4-STABLE-200402010430/TSRM -g -O2 -prefer-pic -c /home/alex/src/test/php4-STABLE-200402010430/sapi/apache/sa pi_apache.c -o sapi/apache/sapi_apache.lo In file included from /usr/lib/apache/include/ap_config.h:116, from /usr/lib/apache/include/httpd.h:72, from /home/alex/src/test/php4-STABLE-200402010430/sapi/apache/php_apache_http.h:22, from /home/alex/src/test/php4-STABLE-200402010430/sapi/apache/sapi_apache.c:24: /usr/lib/apache/include/os.h:141: warning: `DLSYM_NEEDS_UNDERSCORE' redefined /home/alex/src/test/php4-STABLE-200402010430/main/php_config.h:2445: warning: this is the location of the previous definition In file included from /home/alex/src/test/php4-STABLE-200402010430/TSRM/tsrm_config.h:1, from /home/alex/src/test/php4-STABLE-200402010430/TSRM/tsrm_config_common.h:13, from /home/alex/src/test/php4-STABLE-200402010430/TSRM/tsrm_virtual_cwd.h:26, from /home/alex/src/test/php4-STABLE-200402010430/main/php.h:389, from /home/alex/src/test/php4-STABLE-200402010430/main/php_variables.h:25, from /home/alex/src/test/php4-STABLE-200402010430/sapi/apache/php_apache_http.h:40, from /home/alex/src/test/php4-STABLE-200402010430/sapi/apache/sapi_apache.c:24: /home/alex/src/test/php4-STABLE-200402010430/TSRM/../main/php_config.h:2445: warning: `DLSYM_NEEDS_UNDERSCORE' redefined /usr/lib/apache/include/os.h:141: warning: this is the location of the previous definition ------------------------------------------------------------------------ [2004-01-31 23:44:23] sniper@php.net Please try using this CVS snapshot: http://snaps.php.net/php4-STABLE-latest.tar.gz For Windows: http://snaps.php.net/win32/php4-win32-STABLE-latest.zip And try it with this configure line: # ./configure --disable-all --with-apxs ------------------------------------------------------------------------ [2004-01-31 08:30:08] alex dot php at epathology dot com dot au Description: ------------ Trying to compile PHP 4.3.4 with the CLI SAPI module on OpenBSD 3.3 gives the warnings listed under 'actual result' related to the optind and optarg variables. The CLI binary produced then doesn't interpret its command line arguments properly. Fix: This seems to be due to the static optarg and optind variables in sapi/cli/php_cli.c conflicting with those of the standard library. The problem went away when I renamed these two variables. Reproduce code: --------------- ./configure \ --with-config-file-path=/var/www/conf \ --with-apxs \ --with-openssl \ --with-zlib \ --with-iconv \ --with-gettext \ --with-recode \ --with-pgsql \ --without-mysql \ --without-xml \ --enable-inline-optimization \ --enable-shared \ --enable-dio \ --enable-bcmath \ --enable-calendar \ --enable-sockets \ --disable-static make sapi/cli/php --help Expected result: ---------------- Compilation without problems, with help text shown when running 'sapi/cli/php --help'. Actual result: -------------- When the CLI is being compiled the following warnings appear, and then 'sapi/cli/php --help' ignores the --help argument. /bin/sh /home/alex/src/php-4.3.4/libtool --silent --preserve-dup-deps --mode=compile gcc -Isapi/cli/ -I/home/alex/src/php-4.3.4/sapi/cli/ -DPHP_ATOM_INC -I/home/alex/src/php-4.3.4/include -I/home/alex/src/php-4.3.4/main -I/home/alex/src/php-4.3.4 -I/home/alex/src/php-4.3.4/Zend -I/usr/local/include -I/usr/local/pgsql/include -I/home/alex/src/php-4.3.4/ext/xml/expat -I/home/alex/src/php-4.3.4/TSRM -g -O2 -prefer-pic -c /home/alex/src/php-4.3.4/sapi/cli/php_cli.c -o sapi/cli/php_cli.lo /tmp/ccN17837.s: Assembler messages: /tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optind' should be global /tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optarg' should be global /tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optind' should be global /tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optarg' should be global /tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optarg' should be global /tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optarg' should be global /tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optarg' should be global /tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optarg' should be global /tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optarg' should be global /tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optind' should be global /tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optarg' should be global /tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optind' should be global /tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optarg' should be global /tmp/ccN17837.s:3786: Warning: GOT relocation burb: `_optind' should be global /bin/sh /home/alex/src/php-4.3.4/libtool --silent --preserve-dup-deps --mode=link gcc -export-dynamic -g -O2 -L/usr/local/lib -L/usr/local/pgsql/lib -R /usr/local/lib -R /usr/local/pgsql/lib ext/openssl/openssl.lo ext/zlib/zlib.lo (many .lo files) main/internal_functions_cli.lo -lrecode -lpq -liconv -lintl -lz -lssl -lcrypto -lm -o sapi/cli/php ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x1872 ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x1742 ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x1735 ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x1711 ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x16bd ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x1661 ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x164a ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x1609 ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x1420 ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x1413 ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x11c4 ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x11bd ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x1100 ld: sapi/cli/php_cli.lo: relocation must refer to global symbol at 0x10f5 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=27104&edit=1

« previous php.bugs (#54254) next »