php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78946 args missing in Exception within __get
Submitted: 2019-12-11 14:32 UTC Modified: 2019-12-11 14:52 UTC
From: php at usox dot org Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.4.0 OS: Gentoo x64
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at usox dot org
New email:
PHP Version: OS:

 

 [2019-12-11 14:32 UTC] php at usox dot org
Description:
------------
Hi

Exceptions thrown within a __get method lack the `args` array key in the exception backtrace.

This behaviour has been reproduced on three independent systems running Gentoo Linux with different configs. It was _not_ reproducible on 3v4l (see https://3v4l.org/to1qQ).
It looks like the same issue reported in here 10 years ago https://bugs.php.net/bug.php?id=47284

Removing all extensions and modules (last try was a build with just readline enabled) didn't solve the issue.

Ini Changes:
- error_reporting = E_ALL & ~E_STRICT
- memory_limit = 4294967296

Compiler: gcc 9.2
Configuration:
./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --docdir=/usr/share/doc/php-7.4.0 --htmldir=/usr/share/doc/php-7.4.0/html --prefix=/usr/lib64/php7.4 --mandir=/usr/lib64/php7.4/man --infodir=/usr/lib64/php7.4/info --libdir=/usr/lib64/php7.4/lib --with-libdir=lib64 --localstatedir=/var --without-pear --disable-maintainer-zts --without-password-argon2 --enable-bcmath --with-bz2=/usr --disable-calendar --disable-gcov --enable-ctype --with-curl --enable-dom --without-enchant --disable-exif --without-ffi --enable-fileinfo --enable-filter --disable-ftp --with-gettext=/usr --without-gmp --without-mhash --with-iconv --enable-intl --enable-ipv6 --enable-json --without-kerberos --with-libxml --enable-mbstring --with-openssl --enable-pcntl --enable-phar --enable-pdo --enable-opcache --with-pgsql=/usr --enable-posix --without-pspell --enable-simplexml --disable-shmop --without-snmp --enable-soap --enable-sockets --without-sodium --with-sqlite3 --disable-sysvmsg --disable-sysvsem --disable-sysvshm --with-tidy=/usr --enable-tokenizer --enable-xml --enable-xmlreader --enable-xmlwriter --with-xmlrpc --with-xsl --with-zip --with-zlib=/usr --enable-debug --enable-dba --without-cdb --with-db4=/usr --enable-flatfile --with-gdbm=/usr --disable-inifile --without-qdbm --without-tcadb --without-lmdb --with-freetype --disable-gd-jis-conv --with-jpeg --without-xpm --without-webp --enable-gd --with-mysqli=mysqlnd --without-mysql-sock --without-unixODBC --without-iodbc --without-pdo-odbc --without-oci8 --without-pdo-dblib --without-pdo-mysql --with-pdo-pgsql --with-pdo-sqlite --without-pdo-firebird --without-pdo-oci --with-readline=/usr --without-libedit --without-mm --with-pic --with-external-pcre --without-pcre-jit --cache-file=/var/tmp/portage/dev-lang/php-7.4.0/temp/config.cache --with-config-file-path=/etc/php/cli-php7.4 --with-config-file-scan-dir=/etc/php/cli-php7.4/ext-active --disable-embed --enable-cli --disable-cgi --disable-fpm --without-apxs2 --disable-phpdbg


Test script:
---------------
class FooBar {
  public function __get($text) {
    throw new \Exception();
  }   
}
  
try {
  $foobar = new FooBar();
  $foobar->hello;
} catch (\Exception $e) {
  var_dump($e);
}

Expected result:
----------------
object(Exception)#2 (7) {
  ["message":protected]=>
  string(0) ""
  ["string":"Exception":private]=>
  string(0) ""
  ["code":protected]=>
  int(0)
  ["file":protected]=>
  string(28) "/tmp/bug.php"
  ["line":protected]=>
  int(6)
  ["trace":"Exception":private]=>
  array(1) {
    [0]=>
    array(6) {
      ["file"]=>
      string(28) "/tmp/bug.php"
      ["line"]=>
      int(12)
      ["function"]=>
      string(5) "__get"
      ["class"]=>
      string(6) "FooBar"
      ["type"]=>
      string(2) "->"
      ["args"]=>
      array(1) {
        [0]=>
        string(5) "hello"
      }
    }
  }
  ["previous":"Exception":private]=>
  NULL
}

Actual result:
--------------
object(Exception)#2 (7) {
  ["message":protected]=>
  string(0) ""
  ["string":"Exception":private]=>
  string(0) ""
  ["code":protected]=>
  int(0)
  ["file":protected]=>
  string(28) "/tmp/bug.php"
  ["line":protected]=>
  int(6)
  ["trace":"Exception":private]=>
  array(1) {
    [0]=>
    array(5) {
      ["file"]=>
      string(28) "/tmp/bug.php"
      ["line"]=>
      int(12)
      ["function"]=>
      string(5) "__get"
      ["class"]=>
      string(6) "FooBar"
      ["type"]=>
      string(2) "->"
    }
  }
  ["previous":"Exception":private]=>
  NULL
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-12-11 14:52 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2019-12-11 14:52 UTC] nikic@php.net
You have the zend.exception_ignore_args ini setting enabled. Set zend.exception_ignore_args=1 to preserve exception arguments.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 13:01:33 2025 UTC