|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73973 debug_zval_dump() assertion error for resource consts with --enable-debug
Submitted: 2017-01-23 00:40 UTC Modified: 2017-01-24 10:42 UTC
From: tandre at ifwe dot co Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 7.1.1 OS: All/Linux
Private report: No CVE-ID: None
 [2017-01-23 00:40 UTC] tandre at ifwe dot co
This happens when a constant is define()d to be a value with the type resource.

This affects php 7.0.14 and 7.1.0 and 7.1.1, other versions weren't tested.

php-config used:

  --prefix            [/php-7.1.1-install]
  --includes          [-I/php-7.1.1-install/include/php -I/php-7.1.1-install/include/php/main -I/php-7.1.1-install/include/php/TSRM -I/php-7.1.1-install/include/php/Zend -I/php-7.1.1-install/include/php/ext -I/php-7.1.1-install/include/php/ext/date/lib]
  --ldflags           [ -L/usr/lib/x86_64-linux-gnu]
  --libs              [-lcrypt   -lexslt -ltidy -lresolv -lcrypt -lreadline -ltermcap -lrt -lstdc++ -lpng -lz -lcurl -lbz2 -lz -lrt -lm -ldl -lnsl  -lapparmor -lpthread -lxml2 -lssl -lcrypto -lcurl -lxml2 -licui18n -licuuc -licudata -licuio -lxml2 -lxml2 -lcrypt -lxml2 -lxml2 -lxml2 -lxml2 -lxslt -lxml2 -lcrypt ]
  --extension-dir     [/php-7.1.1-install/lib/php/extensions/debug-zts-20160303]
  --include-dir       [/php-7.1.1-install/include/php]
  --man-dir           [/php-7.1.1-install/php/man]
  --php-binary        [/php-7.1.1-install/bin/php]
  --php-sapis         [ cli fpm phpdbg cgi]
  --configure-options [--prefix=/php-7.1.1-install --enable-debug --enable-maintainer-zts --enable-fpm --enable-intl --with-pear --with-gd --with-zlib --enable-soap --enable-xmlreader --with-xsl --with-curl --with-tidy --with-xmlrpc --enable-sysvsem --enable-sysvshm --enable-shmop --enable-pcntl --with-readline --enable-mbstring --with-gettext --enable-sockets --with-bz2 --with-openssl --enable-bcmath --enable-sysvmsg]
  --version           [7.1.1]
  --vernum            [70101]

Test script:
// In CLI, with --enable-debug --enable-maintainer-zts
define('myerr', fopen('php://stderr', 'w'));
// resource(2) of type (stream)
// php: /php-7.1.1/Zend/zend_types.h:822: zval_refcount_p: Assertion `(((*(pz)).u1.v.type_flags & (1<<2)) != 0) || // (((*(pz)).u1.v.type_flags & (1<<1)) != 0)' failed.
// [1]    4964 abort      /php-7.1.1-install/bin/php -a

Expected result:
debug_zval_dump should print information about constant resource and reference counting information without crashing. (When compiled with --enable-debug)

Actual result:
php crashes because of an assertion error when debug_zval_dump is called with a resource assigned to a constant. (Only when compiled with --enable-debug) 


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-24 10:42 UTC]
Something very fishy is being done when defining resources:
 [2017-01-24 13:47 UTC] andrew dot nester dot dev at gmail dot com
I've added PR to GitHub to fix the problem. There also explanation of changes in my PR.
 [2017-01-26 09:05 UTC]
Automatic comment on behalf of
Log: Fixed #73973 - debug_zval_dump() assertion error for resource consts with --enable-debug
 [2017-01-26 09:05 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Dec 11 22:01:28 2023 UTC