Skip to content

Exception on reading property in register-based FETCH_OBJ_R breaks JIT #17747

Closed

Description

@YuanchengJiang

Description

The following code:

<?php
$fusion = $a;
class C {
public int $a;
public function __sleep() {
var_dump($this->a);
}
}
function test(string $name, object $obj) {
$serialized = serialize($obj);
var_dump($serialized, $unserialized);
}
$reflector = new ReflectionClass(C::class);
$obj = $reflector->newLazyGhost(function ($obj) {
}, ReflectionClass::SKIP_INITIALIZATION_ON_SERIALIZE);
test('Ghost', $obj);
try {zip_close($name);} catch (Exception $e) { echo($e); }
try {zip_close($unserialized);} catch (Exception $e) { echo($e); }
try {$cls->override($res);} catch (Exception $e) { echo($e); }
try {$cls->override($serialized);} catch (Exception $e) { echo($e); }

Resulted in this output:

/home/phpfuzz/WorkSpace/flowfusion/php-src/Zend/zend_types.h:1387:9: runtime error: member access within null pointer of type 'zend_refcounted' (aka 'struct _zend_refcounted')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/phpfuzz/WorkSpace/flowfusion/php-src/Zend/zend_types.h:1387:9

To reproduce:

-d "zend_extension=/home/phpfuzz/WorkSpace/flowfusion/php-src/modules/opcache.so" -d "opcache.enable_cli=1" -d "date.timezone=Mars/Utopia_Planitia" -d "opcache.jit=1205"

PHP Version

nightly

Operating System

No response

Activity

  1. deleted a comment from rahulkg123 on Feb 9, 2025
  2. devnexen commented on Feb 9, 2025

    @devnexen
    Member

    could not reproduce it locally

  3. self-assigned this
    on Feb 9, 2025
  4. ndossche commented on Feb 9, 2025

    @ndossche
    Member

    Reproduced for me on an NTS, gcc Linux build

  5. ndossche commented on Feb 9, 2025

    @ndossche
    Member

    Simplified (and no need for the timezone argument):

    <?php
    class C {
        public int $a;
        public function test() {
            var_dump($this->a);
        }
    }
    $test = new C;
    $test->test();
  6. changed the title [-]SEGV Zend/zend_types.h:1387[/-] [+]Exception on reading property in register-based FETCH_OBJ_R breaks JIT[/+] on Feb 9, 2025
  7. added a commit that references this issue on Feb 9, 2025
    026d9ba
  8. deleted a comment from rahulkg123 on Feb 9, 2025
  9. added 2 commits that reference this issue on Feb 11, 2025
    34e1c59
    34d8bef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions