Source: libguestfs
Version: 1:1.60.1-2
Severity: important
Tags: ftbfs patch upstream
Control: block 1149581 by -1

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Hi,

libguestfs fails to build with PHP 8.6, which is in experimental and
becomes the default in unstable with the php8.6 transition (#1149581):

  guestfs_php.c: In function 'get_stringlist':
  guestfs_php.c:3787:5: error: implicit declaration of function 'zval_dtor' 
[-Wimplicit-function-declaration]

PHP 8.6 removed the zval_dtor() alias of zval_ptr_dtor_nogc() (see
UPGRADING.INTERNALS).  php/extension/guestfs_php.c is generated by
generator/php.ml.

The attached patch calls zval_ptr_dtor_nogc() instead.  It changes the
generator and the generated file that the tarball ships, because the
Debian build runs the generator again.  zval_dtor() has been a macro for
exactly that since PHP 7.3, so nothing changes with PHP 8.4.  The call
in the PHP 5 branch of the surrounding #if is left as it is.

I did not find a fix upstream: generator/php.ml on master still calls
zval_dtor().  The patch has not been sent upstream yet.

With the patch, in an sbuild chroot with php8.6 8.6.0-3 and php-defaults
108~exp2 from experimental, the full build succeeds, "make quickcheck"
included.  debian/rules does not run the tests of the PHP binding, so I
ran them after the build in the same chroot (make -C debian/build-1/php
check): all 6 pass with PHP 8.6.0.

I did not build the patched package with PHP 8.4 in unstable.  The
patched guestfs_php.c compiles (gcc -fsyntax-only) against the PHP 8.4
headers.


- -- System Information:
Debian Release: 13.8
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 
'stable-debug'), (500, 'proposed-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.12.117+deb13-amd64 (SMP w/12 CPU threads; PREEMPT)
Locale: LANG=en_IE.UTF-8, LC_CTYPE=en_IE.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_IE:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)

-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEw2Gx4wKVQ+vGJel9g3Kkd++uWcIFAmsKtjpfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldEMz
NjFCMUUzMDI5NTQzRUJDNjI1RTk3RDgzNzJBNDc3RUZBRTU5QzIACgkQg3Kkd++u
WcLHcA//aIUSsIL/aO1phzKQYVr2Q1MD4dSVirl49SNu+NYy1j8q5hpofBdsy0+/
5QuQvFrb959k2RNuPegwSq5DKhlF6heeCt/2FN9mq6L+oG4dhh3tEhY+gASjXo6a
zFpaz6Dbuh+UyIrDncor4QC9KG0jbdy+obS3aeeZYRwE3zMNJSjyRs8ccxj1Kk+k
grgYIpQbmJ9z8FaAxOzWqrCX+n0Kvn2zgrpW3kGfYOJVH7k7XlK93aIfezHW1Trm
Q+OuTPFYvHjDa1Yt0kkRcZScLksPpfEportMKNtqMZaPjMdS5xja3BJsd1mgOBdm
vjY/mBFsNd5tj8pf2gpEQ5Yr/czbk2l4LK+COq60yMTyFKvKJEQKVXUDNZ9pT88N
xTiOu8Cj1gzyg9j9/mcOtXbyoadUHU8eUesEQNoDwIpm2mQTN2IdHcJ4m6owChTr
rJyrDmOr9YWf1eBxCjB5U5BHnOt6mZKNc/jnNsUTE/HRlWuJngNIQQX+z4r21vjH
S4e8xK2pO0mk7lOHXowoEzLVhwTfsL+TF0ZxbrB4CVp7LXE9VdJXauUILFVeHUD4
VtDH8iGaK2JwZEqRVlxRABE5DD2ccWqCKALuK8WtnBhK/xhnigONFAcrkJmVIadf
T5c/YVY2blGvzQIFINvONFwuYUf+//ZWV5HQUnPyl2qEM1Wl12M=
=h42t
-----END PGP SIGNATURE-----
Description: php: Do not use zval_dtor(), which PHP 8.6 removed
 PHP 8.6 removed zval_dtor(), which had only been an alias of
 zval_ptr_dtor_nogc() since PHP 7.3.  The PHP bindings then fail to build:
 .
   guestfs_php.c: In function 'get_stringlist':
   guestfs_php.c:3787:5: error: implicit declaration of function 'zval_dtor'
 .
 Call zval_ptr_dtor_nogc() instead, which exists since PHP 7.0.  The value
 being released is the temporary string copy made a few lines above, so
 the behaviour does not change.  The old call is kept for the PHP 5 branch
 of the surrounding #if blocks.
 .
 The generator is patched together with the generated file that the
 tarball ships, because the Debian build runs the generator again.
Author: Ondřej Surý <[email protected]>
Forwarded: no
Last-Update: 2026-11-28

--- a/generator/php.ml
+++ b/generator/php.ml
@@ -193,7 +193,11 @@
     zval_copy_ctor (&t);
     convert_to_string (&t);
     ret[c] = estrndup (Z_STRVAL(t), Z_STRLEN (t));
+#if ZEND_MODULE_API_NO >= 20151012
+    zval_ptr_dtor_nogc (&t);
+#else
     zval_dtor (&t);
+#endif
     c++;
   }
   ret[c] = NULL;
--- a/php/extension/guestfs_php.c
+++ b/php/extension/guestfs_php.c
@@ -3784,7 +3784,11 @@
     zval_copy_ctor (&t);
     convert_to_string (&t);
     ret[c] = estrndup (Z_STRVAL(t), Z_STRLEN (t));
+#if ZEND_MODULE_API_NO >= 20151012
+    zval_ptr_dtor_nogc (&t);
+#else
     zval_dtor (&t);
+#endif
     c++;
   }
   ret[c] = NULL;

Reply via email to