php / php-src

The PHP Interpreter
https://www.php.net
Other
38.28k stars 7.76k forks source link

Assertion `jit->ra[var].flags & (1<<0)' failed #16837

Open danog opened 1 week ago

danog commented 1 week ago

Description

Got the following assertion when running multiple Psalm unit tests:

ext/opcache/jit/zend_jit_ir.c:1386: zend_jit_use_reg: Assertion `jit->ra[var].flags & (1<<0)' failed.

Config is in https://github.com/php/php-src/pull/12406, reproducer command is:

php --repeat 2 -f .github/jit_check.php /tmp/psalm/vendor/bin/phpunit /tmp/psalm/tests/LanguageServer/FileMapTest.php

PHP Version

nightly

Operating System

No response

iluuu1994 commented 6 days ago

/cc @dstogov

dstogov commented 5 days ago

This may be fixed via https://github.com/php/php-src/commit/ef5844a1caed0838b4389bf51c6032265842581a

I wasn't able to reproduce the reported assertion, but got a crash instead. The commit above fixed the crash. Assertion is not reproducible.

danog commented 4 days ago

@dstogov Thanks! Seems okay, but still getting some segfaults on tests/AnnotationTest.php and several others (currently testing on arm64).

Reproduce by cloning and running php .github/nightly.php with the following ini:

memory_limit = -1
zend.assertions = 1
display_errors = On
display_startup_errors = On

[opcache]
zend_extension=opcache.so

opcache.memory_consumption=4096M
opcache.enable=1
opcache.enable_cli=1
opcache.jit=tracing
opcache.validate_timestamps=0
opcache.jit_buffer_size=128M
opcache.file_update_protection=0
opcache.max_accelerated_files=1000000
opcache.interned_strings_buffer=64

opcache.jit_prof_threshold=0.000000001
opcache.jit_max_root_traces=  100000
opcache.jit_max_side_traces=  100000
opcache.jit_max_exit_counters=100000
opcache.jit_hot_loop=1
opcache.jit_hot_func=1
opcache.jit_hot_return=1
opcache.jit_hot_side_exit=1

opcache.jit_blacklist_root_trace=255
opcache.jit_blacklist_side_trace=255

opcache.protect_memory=1
danog commented 3 days ago

@dstogov Sorry, I meant to link the repo https://github.com/danog/php-src for the reproducer :)

Reproduce by cloning https://github.com/danog/php-src and running php .github/nightly.php with the following ini:

memory_limit = -1
zend.assertions = 1
display_errors = On
display_startup_errors = On

[opcache]
zend_extension=opcache.so

opcache.memory_consumption=4096M
opcache.enable=1
opcache.enable_cli=1
opcache.jit=tracing
opcache.validate_timestamps=0
opcache.jit_buffer_size=128M
opcache.file_update_protection=0
opcache.max_accelerated_files=1000000
opcache.interned_strings_buffer=64

opcache.jit_prof_threshold=0.000000001
opcache.jit_max_root_traces=  100000
opcache.jit_max_side_traces=  100000
opcache.jit_max_exit_counters=100000
opcache.jit_hot_loop=1
opcache.jit_hot_func=1
opcache.jit_hot_return=1
opcache.jit_hot_side_exit=1

opcache.jit_blacklist_root_trace=255
opcache.jit_blacklist_side_trace=255

opcache.protect_memory=1