Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set of opcache tests fail zts+aarch64 8.4.1 #16902

Closed
andypost opened this issue Nov 23, 2024 · 23 comments
Closed

Set of opcache tests fail zts+aarch64 8.4.1 #16902

andypost opened this issue Nov 23, 2024 · 23 comments

Comments

@andypost
Copy link
Contributor

Description

Building ZTS packages for Alpinelinux for 8.4.1 I got a set of failed tests and all of them related to opcache

ref https://gitlab.alpinelinux.org/alpine/aports/-/jobs/1615413

# JIT and OpCache related tests to disable
ext/opcache/tests/bug81272.phpt
ext/opcache/tests/gh16186_001.phpt
ext/opcache/tests/gh16186_002.phpt
ext/opcache/tests/jit/assign_obj_002.phpt
ext/opcache/tests/jit/bool_not_001.phpt
ext/opcache/tests/jit/bug77857.phpt
ext/opcache/tests/jit/bug79888.phpt
ext/opcache/tests/jit/bug80634.phpt
ext/opcache/tests/jit/bug80745.phpt
ext/opcache/tests/jit/bug80786.phpt
ext/opcache/tests/jit/bug80802.phpt
ext/opcache/tests/jit/bug80839.phpt
ext/opcache/tests/jit/bug80861.phpt
ext/opcache/tests/jit/bug80959.phpt
ext/opcache/tests/jit/bug81051.phpt
ext/opcache/tests/jit/bug81225.phpt
ext/opcache/tests/jit/bug81225_2.phpt
ext/opcache/tests/jit/bug81226.phpt
ext/opcache/tests/jit/bug81249.phpt
ext/opcache/tests/jit/bug81255.phpt
ext/opcache/tests/jit/bug81256.phpt
ext/opcache/tests/jit/bug81409.phpt
ext/opcache/tests/jit/cast_001.phpt
ext/opcache/tests/jit/defined_001.phpt
ext/opcache/tests/jit/fetch_dim_r_005.phpt
ext/opcache/tests/jit/fetch_obj_005.phpt
ext/opcache/tests/jit/gh12380.phpt
ext/opcache/tests/jit/gh15490.phpt
ext/opcache/tests/jit/gh8461-001.phpt
ext/opcache/tests/jit/gh8461-002.phpt
ext/opcache/tests/jit/gh8461-003.phpt
ext/opcache/tests/jit/gh8461-004.phpt
ext/opcache/tests/jit/gh8461-005.phpt
ext/opcache/tests/jit/gh8461-006.phpt
ext/opcache/tests/jit/gh8461-007.phpt
ext/opcache/tests/jit/gh8461-008.phpt
ext/opcache/tests/jit/gh8591-001.phpt
ext/opcache/tests/jit/gh8591-002.phpt
ext/opcache/tests/jit/gh8591-003.phpt
ext/opcache/tests/jit/gh8591-004.phpt
ext/opcache/tests/jit/gh8591-005.phpt
ext/opcache/tests/jit/gh8591-006.phpt
ext/opcache/tests/jit/hot_func_002.phpt
ext/opcache/tests/jit/ignored_opcodes.phpt
ext/opcache/tests/jit/init_fcall_003.phpt
ext/opcache/tests/jit/loop_002.phpt
ext/opcache/tests/jit/mod_003.phpt
ext/opcache/tests/jit/mul_005.phpt
ext/opcache/tests/jit/oss-fuzz-64727.phpt
ext/opcache/tests/jit/reg_alloc_004.phpt
ext/opcache/tests/jit/trampoline_001.phpt
ext/opcache/tests/jit/trampoline_002.phpt

PHP Version

PHP 8.4.1

Operating System

Alpinelinux

@andypost
Copy link
Contributor Author

andypost commented Nov 23, 2024

it fail only on aarch64

TEST 10325/18580 [ext/opcache/tests/jit/reg_alloc_004.phpt]
========DIFF========
--
     Warning: Undefined variable $d in %sreg_alloc_004.php on line 7
     
     Warning: Undefined variable $d in %sreg_alloc_004.php on line 7
008- 
009- Fatal error: Uncaught Error: First array member is not a valid class name or object in %sreg_alloc_004.php:7
010- Stack trace:
011- #0 %sreg_alloc_004.php(7): createTree(0)
012- #1 %sreg_alloc_004.php(7): createTree(1)
013- #2 %sreg_alloc_004.php(7): createTree(2)
014- #3 %sreg_alloc_004.php(9): createTree(3)
015- #4 {main}
016-   thrown in %sreg_alloc_004.php on line 7
========DONE========
FAIL Register Alloction 004: Check guard before register load [ext/opcache/tests/jit/reg_alloc_004.phpt] 

TEST 10365/18580 [ext/opcache/tests/jit/trampoline_001.phpt]
========DIFF========
001- BBBCCC
001+ B
========DONE========
FAIL JIT Trampoline 001: trampoline cleanup [ext/opcache/tests/jit/trampoline_001.phpt] 
TEST 10366/18580 [ext/opcache/tests/jit/trampoline_002.phpt]
========DIFF========
001- BBBCCCDDDCCC
001+ B
========DONE========
FAIL JIT Trampoline 002: trampoline cleanup [ext/opcache/tests/jit/trampoline_002.phpt] 

@andypost
Copy link
Contributor Author

TEST 10300/18580 [ext/opcache/tests/jit/oss-fuzz-64727.phpt]
========DIFF========
001- int(0)
002- int(3)
003- int(3)
004- NULL
001+ 
========DONE========
FAIL oss-fuzz #64727 [ext/opcache/tests/jit/oss-fuzz-64727.phpt] 

@nielsdos
Copy link
Member

Hm, this could be related to the TSRM cache tcb offset, if this is not fully supported on ARM64+MUSL.
Just to be clear: this does work on versions lower than 8.4 ? Does a debug build give any assertion failure?

@andypost
Copy link
Contributor Author

Previously I did not build zts so no previous state, debug -g was added but I did not debug yet, strange that it pass on loongarch64 and armv7/hf(32-bit)

@andypost
Copy link
Contributor Author

building with --enable-debug-assertions

@andypost
Copy link
Contributor Author

andypost commented Nov 23, 2024

Yes, there's assertions now

TEST 10365/18580 [ext/opcache/tests/jit/trampoline_001.phpt]
========DIFF========
001- BBBCCC
001+ Assertion failed: tsrm_ls_cache_tcb_offset != 0 (ext/opcache/jit/zend_jit_ir.c: zend_jit_setup: 3237)
========DONE========
FAIL JIT Trampoline 001: trampoline cleanup [ext/opcache/tests/jit/trampoline_001.phpt] 
TEST 10366/18580 [ext/opcache/tests/jit/trampoline_002.phpt]
========DIFF========
001- BBBCCCDDDCCC
001+ Assertion failed: tsrm_ls_cache_tcb_offset != 0 (ext/opcache/jit/zend_jit_ir.c: zend_jit_setup: 3237)
========DONE========
FAIL JIT Trampoline 002: trampoline cleanup [ext/opcache/tests/jit/trampoline_002.phpt] 

@andypost
Copy link
Contributor Author

all of them are the same!

TEST 10026/18580 [ext/opcache/tests/jit/assign_dim_003.phpt]
========DIFF========
001- Warning: Undefined variable $v in %sassign_dim_003.php on line 3
002- NULL
001+ Assertion failed: tsrm_ls_cache_tcb_offset != 0 (ext/opcache/jit/zend_jit_ir.c: zend_jit_setup: 3237)
========DONE========
FAIL JIT ASSIGN_DIM: 003 [ext/opcache/tests/jit/assign_dim_003.phpt] 

@nielsdos
Copy link
Member

nielsdos commented Nov 24, 2024

Thanks! Right, so my suspicion that this is missing MUSL TSRM TLS support is right.
Annoyingly I don't have Arm64 hardware, but I can look into this maybe via emulation...

@nielsdos
Copy link
Member

@andypost Can you please try the following patch? https://gist.github.com/nielsdos/acdcc7c3cab51d42df6eec41f50eb5e3
This fixes the issue for me. This applies on PHP-8.4. Lower branches (i.e. versions below 8.4) will need a slightly different patch.

@andypost
Copy link
Contributor Author

Thank you, I will try as php.net will be back

@andypost
Copy link
Contributor Author

@nielsdos Thank you a lot! now it passed all tests!

@nielsdos
Copy link
Member

Thanks for checking @andypost , now I need to split this into different PRs because one part needs to go in php-src and another one in https://github.com/dstogov/ir

@andypost
Copy link
Contributor Author

andypost commented Nov 24, 2024

Attempted 8.3 build and it has more failures, moreover lots fails on 32-bits

nielsdos added a commit to nielsdos/php-src that referenced this issue Nov 24, 2024
@nielsdos
Copy link
Member

@andypost This is the patch that should fix ZTS+JIT+Aarch64 on Alpine for PHP 8.2 and 8.3: #16925

Can you link also the 32-bit failures? Do you mean x86 32 bit or ARM 32 bit? Only the former has JIT.

@nielsdos
Copy link
Member

Note that I force pushed this 8.2-8.3 PR a few minutes ago, so if you had tested in the meantime I have updated the patch

@andypost
Copy link
Contributor Author

Thank you! ARM passed, the only x86 (32-bit) failure

TEST 6756/17235 [ext/ffi/tests/gh14626.phpt]
========DIFF========
001- ==DONE==
001+ zend_mm_heap corrupted
========DONE========
FAIL GH-14626: FFI::free() may crash in is_zend_ptr() when at least one huge block exists and the ptr is non-zend [ext/ffi/tests/gh14626.phpt] 

dstogov pushed a commit to dstogov/ir that referenced this issue Nov 25, 2024
@andypost
Copy link
Contributor Author

@nielsdos many thanks! all arches passed, btw x86 failure is random somehow
Probably MM issue on musl still exist and I gonna explore https://frankenphp.dev/docs/performance/#dont-use-musl

@andypost
Copy link
Contributor Author

Can you link also the 32-bit failures?

often fails on 32-bits both arm and x86

TEST 6757/17242 [ext/ffi/tests/gh14626.phpt]
========DIFF========
001- ==DONE==
001+ zend_mm_heap corrupted
========DONE========
FAIL GH-14626: FFI::free() may crash in is_zend_ptr() when at least one huge block exists and the ptr is non-zend [ext/ffi/tests/gh14626.phpt] 

and this one I even disabled for few arches as it very unstable

TEST 6130/17242 [ext/dba/tests/dba_gdbm.phpt]
========DIFF========
--
     bool(true)
     Try to remove key 1 again
     bool(false)
013- key4: Another Content String
013+ [key30]name30: Content String 30
014+ key5: The last content string
015+ name9: Content String 9
     key2: Content String 2
015- key5: The last content string
     [key10]name10: Content String 10
017- name9: Content String 9
018- [key30]name30: Content String 30
018+ key4: Another Content String
     Total keys: 6
     Key 1 exists? N
     Key 2 exists? Y
--
     bool(true)
     Try to remove key 1 again
     bool(false)
059- key4: Another Content String
059+ [key30]name30: Content String 30
060+ key5: The last content string
061+ name9: Content String 9
     key2: Content String 2
061- key5: The last content string
     [key10]name10: Content String 10
063- name9: Content String 9
064- [key30]name30: Content String 30
064+ key4: Another Content String
     Total keys: 6
     Key 1 exists? N
     Key 2 exists? Y
--
========DONE========
FAIL DBA GDBM handler test [ext/dba/tests/dba_gdbm.phpt] 

nielsdos added a commit that referenced this issue Nov 25, 2024
* PHP-8.2:
  Fix GH-16902: Set of opcache tests fail zts+aarch64 (8.2-8.3)
nielsdos added a commit that referenced this issue Nov 25, 2024
* PHP-8.3:
  Fix GH-16902: Set of opcache tests fail zts+aarch64 (8.2-8.3)
nielsdos added a commit that referenced this issue Nov 25, 2024
nielsdos added a commit that referenced this issue Nov 25, 2024
* PHP-8.4:
  Fix GH-16902: Set of opcache tests fail zts+aarch64 (8.4+)
  Fix GH-16902: Set of opcache tests fail zts+aarch64 (8.2-8.3)
@nielsdos
Copy link
Member

@andypost I fixed the ZTS issue, hence this issue was closed.

About your other two issues:

  1. I'll try to have a look at the FFI issue, I need to setup a Docker container for i386 Alpine though so that may take a little bit.
  2. The gdbm issue is actually this: ext/dba/tests: sort expected test output #14962 It turns out that the test file was missing a sort. I'll ask in that PR if this should be backported.

@nielsdos
Copy link
Member

@andypost I can reproduce that FFI issue but have not fully understood it yet. I know that the reason for the crash is that is_zend_ptr() for some reason returned 1 instead of 0, I'm debugging further...

nielsdos added a commit to nielsdos/php-src that referenced this issue Nov 25, 2024
We should compare the block memory, not the block metadata (See
zend_mm_add_huge_block).
This caused random test failure for ext/ffi/tests/gh14626.phpt when the
malloc() performed by the FFI code lies close to the block metadata, and
the size of the block is large enough.

This was reported by php#16902 (comment)
@nielsdos
Copy link
Member

@andypost I have identified the problem and propose this patch: #16938

nielsdos added a commit that referenced this issue Nov 26, 2024
We should compare the block memory, not the block metadata (See
zend_mm_add_huge_block).
This caused random test failure for ext/ffi/tests/gh14626.phpt when the
malloc() performed by the FFI code lies close to the block metadata, and
the size of the block is large enough.

This was reported by #16902 (comment)

Closes GH-16938.
@nielsdos
Copy link
Member

@andypost Everything you reported, including that gdbm issue, should now be fixed in the next releases of 8.2,8.3,8.4.

@andypost
Copy link
Contributor Author

@nielsdos Thank you a lot!

I'm waiting for RC1 releases to start with ZTS!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants