php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64833 ext/sockets/sendrecvmsg.c related compilation errors
Submitted: 2013-05-13 21:49 UTC Modified: 2020-03-23 17:41 UTC
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: clicky at erebot dot net Assigned: cmb (profile)
Status: Closed Package: Compile Failure
PHP Version: 7.1.0alpha3 OS: Debian Stretch
Private report: No CVE-ID: None
 [2013-05-13 21:49 UTC] clicky at erebot dot net
Description:
------------
While trying to build PHP 5.5.0RC1 under Debian Squeeze, the following compilation errors were triggered.

I think this may be related to this commit that introduced support for SCM_CREDENTIALS and other goodies in the sockets extension recently: http://git.php.net/?p=php-src.git;a=commitdiff;h=a85d7f28f69fbc522ed90aee1926d3733be7620d

Also, please note that the manpage for UNIX sockets states that "struct ucred" (which is used in the code) is only defined when the _GNU_SOURCE macro is defined since glibc 2.8 [1]. This may also be the reason why the build fails (Debian Squeeze uses libc6-2.13 [2]).

Other projects have been impacted by this issue too [3].

[1] http://manpages.ubuntu.com/manpages/karmic/en/man7/unix.7.html
[2] http://packages.debian.org/wheezy/libc6
[3] http://sourceforge.net/p/wide-dhcpv6/bugs/29/ (also contains link to a glibc commit that changed some of the structs like in6_pktinfo to be macro-guarded).

Test script:
---------------
'./configure' \
'--enable-debug' \
'--disable-all' \
'--disable-short-tags' \
'--disable-sigchild' \
'--with-layout=GNU' \
'--with-regex' \
'--with-openssl=shared' \
'--with-zlib=shared' \
'--enable-bcmath=shared' \
'--with-bz2=shared' \
'--enable-calendar=shared' \
'--with-gettext=shared' \
'--enable-mbstring=shared' \
'--enable-pcntl=shared' \
'--enable-sockets=shared' \
'--with-pdo-sqlite' \
'--enable-sysvmsg=shared' \
'--enable-sysvsem=shared' \
'--enable-sysvshm=shared' \
'--with-xsl=shared' \
'--with-iconv=shared' \
'--enable-zip=shared' \
'--enable-posix=shared' \
'--enable-libxml=shared' \
'--enable-dom=shared' \
'--enable-xml=shared' \
'--enable-xmlreader=shared' \
'--enable-xmlwriter=shared' \
'--enable-tokenizer=shared' \
'--enable-pdo' \
'--enable-ctype=shared' \
'--enable-json=shared' \
'--enable-session=shared' \
'--enable-soap=shared' \
'--enable-simplexml=shared' \
'--enable-hash' \
'--enable-intl=shared' \
'--enable-phar=shared' \
'--with-sqlite3' \
'--with-mysql=shared,mysqlnd' \
'--with-mysqli=shared,mysqlnd' \
'--with-pdo-mysql=shared,mysqlnd' \
'--prefix=/home/qa/phpfarm/inst/php-5.5.0RC1-debug' \
'--exec-prefix=/home/qa/phpfarm/inst/php-5.5.0RC1-debug' \
'--without-pear' \
'--enable-cgi' \
'--enable-cli' \
'--enable-fpm' \
"$@"

(but could probably be reduced to just ./configure --disable-all --enable-sockets=shared)

Expected result:
----------------
PHP should build without any compilation error.

Actual result:
--------------
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/sendrecvmsg.c: In function ‘init_ancillary_registry’:
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/sendrecvmsg.c:109:2: error: invalid application of ‘sizeof’ to incomplete type ‘struct in6_pktinfo’
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/sendrecvmsg.c:124:2: error: invalid application of ‘sizeof’ to incomplete type ‘struct ucred’
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/sendrecvmsg.c:124:2: error: ‘SCM_CREDENTIALS’ undeclared (first use in this function)
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/sendrecvmsg.c:124:2: note: each undeclared identifier is reported only once for each function it appears in
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/sendrecvmsg.c: In function ‘php_do_setsockopt_ipv6_rfc3542’:
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/sendrecvmsg.c:339:12: error: invalid application of ‘sizeof’ to incomplete type ‘struct in6_pktinfo’
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/sendrecvmsg.c:345:19: error: invalid application of ‘sizeof’ to incomplete type ‘struct in6_pktinfo’
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/sendrecvmsg.c: In function ‘php_do_getsockopt_ipv6_rfc3542’:
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/sendrecvmsg.c:377:17: error: invalid application of ‘sizeof’ to incomplete type ‘struct in6_pktinfo’
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/sendrecvmsg.c: In function ‘php_socket_sendrecvmsg_init’:
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/sendrecvmsg.c:436:2: error: ‘SCM_CREDENTIALS’ undeclared (first use in this function)
make: *** [ext/sockets/sendrecvmsg.lo] Error 1


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-05-15 12:48 UTC] dsp@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: cataphract
 [2013-05-16 19:32 UTC] clicky at erebot dot net
Adding to my initial report.
Compiling with ./configure --disable-all --enable-sockets also triggers this issue, although with a different output:

/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/conversions.c:1288:31: error: invalid use of undefined type ‘struct in6_pktinfo’
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/conversions.c:1289:37: error: invalid use of undefined type ‘struct in6_pktinfo’
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/conversions.c:1307:29: error: invalid use of undefined type ‘struct ucred’
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/conversions.c:1307:29: error: initializer element is not constant
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/conversions.c:1307:29: error: (near initialization for ‘descriptors_ucred[0].field_offset’)
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/conversions.c:1308:29: error: invalid use of undefined type ‘struct ucred’
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/conversions.c:1308:29: error: initializer element is not constant
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/conversions.c:1308:29: error: (near initialization for ‘descriptors_ucred[1].field_offset’)
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/conversions.c:1310:29: error: invalid use of undefined type ‘struct ucred’
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/conversions.c:1310:29: error: initializer element is not constant
/home/qa/phpfarm/src/php-5.5.0RC1-debug/ext/sockets/conversions.c:1310:29: error: (near initialization for ‘descriptors_ucred[2].field_offset’)
make: *** [ext/sockets/conversions.lo] Error 1
 [2015-05-08 00:37 UTC] clicky at erebot dot net
-Status: Assigned +Status: Closed
 [2015-05-08 00:37 UTC] clicky at erebot dot net
Closing this bug as I cannot reproduce it in stable releases.
 [2016-07-11 15:21 UTC] clicky at erebot dot net
-Status: Closed +Status: Assigned -Operating System: Debian Squeeze +Operating System: Debian Stretch -PHP Version: 5.5.0RC1 +PHP Version: 7.1.0alpha3
 [2016-07-11 15:21 UTC] clicky at erebot dot net
Now I'm seeing errors like this one when compiling PHP 7.1.0alpha3:

In file included from /usr/include/rpc/netdb.h:42:0,
                 from /usr/include/netdb.h:32,
                 from .../phpfarm/src/php-7.1.0alpha3-debug/main/php_network.h:79,
                 from .../phpfarm/src/php-7.1.0alpha3-debug/ext/sockets/sockaddr_conv.h:4,
                 from .../phpfarm/src/php-7.1.0alpha3-debug/ext/sockets/conversions.c:1:
.../phpfarm/src/php-7.1.0alpha3-debug/ext/sockets/conversions.c:1291:47: error: invalid use of undefined type ‘struct in6_pktinfo’
   {"addr", sizeof("addr"), 1, offsetof(struct in6_pktinfo, ipi6_addr), from_zval_write_sin6_addr, to_zval_read_sin6_addr},

It seems some of the structures like in6_pktinfo (from netinet/in.h) and ucred (from bits/socket.h) are not exposed in glibc headers anymore (at least with glibc 2.22) unless -D_GNU_SOURCE is used in the CFLAGS.  That's because those structures are now guarded with the _USE_GNU preprocessor macro.
 [2017-10-16 20:32 UTC] peterkokot at gmail dot com
Hello, I've tried compiling PHP 7.1.10 on Debian 9 and it goes through without any patches required so far. Used procedure:
./configure --disable-all --enable-sockets=shared
make

I believe the compilation issues have been fixed in the mentioned problematic file and got into PHP 7.1.x release:
https://github.com/php/php-src/commits/master/ext/sockets/conversions.c

I believe we can close this issue since also according to some Docker images based on Debian 8 and 9 the compilation goes through ok. In case the issue is still relevant, you we can reopen this ticket anytime anyway. Thanks.
 [2020-03-10 09:17 UTC] cmb@php.net
-Status: Assigned +Status: Feedback -Assigned To: cataphract +Assigned To: cmb
 [2020-03-10 09:17 UTC] cmb@php.net
Is this still an issue for any of the actively supported PHP
versions[1]?

[1] <https://www.php.net/supported-versions.php>
 [2020-03-22 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2020-03-23 17:41 UTC] clicky at erebot dot net
-Status: No Feedback +Status: Closed
 [2020-03-23 17:41 UTC] clicky at erebot dot net
I haven't been able to reproduce this in any recent release.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Mar 29 22:01:26 2020 UTC