php.net |  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
Description:
------------
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'));
var_dump(myerr);
// resource(2) of type (stream)
debug_zval_dump(myerr);
// 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) 

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-24 10:42 UTC] nikic@php.net
Something very fishy is being done when defining resources: https://github.com/php/php-src/blob/master/Zend/zend_builtin_functions.c#L928
 [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] krakjoe@php.net
Automatic comment on behalf of andrew.nester.dev@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f65ae82c55b986fbc1e140de998b4a9c44911cac
Log: Fixed #73973 - debug_zval_dump() assertion error for resource consts with --enable-debug
 [2017-01-26 09:05 UTC] krakjoe@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 08:01:29 2024 UTC