Repository navigation
Closed
Description
Description
The following code: https://github.com/nicelocal/psalm/tree/rector_pass (a fork of Psalm, commit 9d3fee47afa90f3eb53043a26f01e587d2dd34e5)
Running using (the xdebug env is used to avoid overwriting the opcache config, xdebug is not installed nor enabled):
PSALM_ALLOW_XDEBUG=1 USE_ZEND_ALLOC=0 gdb --args php-asan ./psalm --no-cache
With this config:
memory_limit = -1
zend.assertions = 1
display_errors = On
display_startup_errors = On
;extension=uv
extension=gmp
extension=iconv
[opcache]
zend_extension=opcache
opcache.memory_consumption=4096M
opcache.enable=1
opcache.enable_cli=1
opcache.jit=tracing
opcache.validate_timestamps=0
opcache.jit_buffer_size=1G
opcache.file_update_protection=0
opcache.max_accelerated_files=1000000
opcache.interned_strings_buffer=64
;opcache.jit_debug=28672
;opcache.jit_debug=16384
opcache.jit_debug=256
opcache.jit_prof_threshold=0.000000001
opcache.jit_max_root_traces= 30000000
opcache.jit_max_side_traces= 30000000
opcache.jit_max_exit_counters=30000000
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
Resulted in this output:
Program received signal SIGABRT, Aborted.
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
44 return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0;
(gdb) back
#0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1 0x00007ffff6ffa8a3 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2 0x00007ffff6faa668 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3 0x00007ffff6f924b8 in __GI_abort () at abort.c:79
#4 0x00007fffb180a457 in TRACE-1550$Psalm\Type\Union::getSingleAtomic$1527 () at unknown:1
#5 0x00007ffff48035f8 in ?? ()
#6 0x00007ffff48035f0 in ?? ()
#7 0x00007ffff48035f0 in ?? ()
#8 0x00000000f48035f0 in ?? ()
#9 0x5dfaca7550574600 in ?? ()
#10 0x0000000173596764 in ?? ()
#11 0x00007ffff4803800 in ?? ()
#12 0x0000555557d28798 in ?? ()
#13 0x00007ffff7ffd000 in ?? () from /lib64/ld-linux-x86-64.so.2
#14 0x00007fffffffde88 in ?? ()
#15 0x0000000000000000 in ?? ()
(gdb) zback
[0x7ffff4803830] Psalm\Type\Union->getSingleAtomic() /home/daniil/repos/psalm/src/Psalm/Type/UnionTrait.php:1527
[0x7ffff48035f0] Psalm\Internal\Analyzer\Statements\Expression\SimpleTypeInferer->infer(object[0x7ffff4803640], object[0x7ffff4803650],
object[0x7ffff4803660], object[0x7ffff4803670], NULL, array(0)[0x7ffff4803690], "Composer\Autoload\ComposerStaticInitee60cb38244924a30b9a4f1eb3dba
But I expected this output instead: no abortion.
ping @dstogov
PHP Version
master
Operating System
Arch linux
Activity
danog commentedon Oct 23, 2023
A better reproducer: https://github.com/danog/jit_bugs (test 2).
Fixed GH-12482: Abortion with tracing JIT
Merge branch 'PHP-8.1' into PHP-8.2
Merge branch 'PHP-8.2' into PHP-8.3
Merge branch 'PHP-8.3'
dstogov commentedon Oct 24, 2023
Thanks for the https://github.com/danog/jit_bugs repo. The test 2 should be fixed now.
Test 1 is actually reported at #11795
Should I take a look into others?
danog commentedon Oct 24, 2023
Hi @dstogov, thanks!
It seems like issue 2 is still present on master (a heap overflow with ASAN, since the fix only affected the old JIT).
Thanks for the info on issue 1, regarding the other issues, I think they can mostly be ignored, except for the last one (5), which is actually causing a GC infinite loop hang after several hours of execution, it's particularly nasty to reproduce, will try to whip up a better reproducer...
danog commentedon Oct 24, 2023
Additionally, there's an issue with fibers unrelated to JIT or opcache that causes memory corruption in certain cases if a fiber is resumed after an exception in the shutdown handler, I've been seeing a lot of reports including in the amphp chat, and got the issue myself several times (an impossible TypeError on corrupted return values), but haven't managed to reliably reproduce yet...
The only way of sometimes reproducing the issue is running reproducer 3 and randomly hitting ctrl-c multiple times during the handshake, but still it's super hard to reproduce reliably...
dstogov commentedon Oct 24, 2023
I think this is a different issue. New JIT avoided this error out of the box. BTW I also see a heap-buffer-overflow on test 2 with PHP-8.3. This is definitely a different problem.
The problem that this error occurs after an hour of work :(
dstogov commentedon Oct 24, 2023
The last heap-buffer-overflow should be fixed now in PHP-8.1 and above