Skip to content

Fix GH-16168: php 8.1 and earlier crash immediately when compiled with Xcode 16 clang on macOS 15 #16348

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions Zend/zend_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,32 +392,32 @@ ZEND_API bool ZEND_FASTCALL I_REPLACE_SONAME_FNNAME_ZU(NONE,zend_string_equal_va
ZEND_API zend_never_inline NOIPA bool ZEND_FASTCALL zend_string_equal_val(const zend_string *s1, const zend_string *s2)
{
const char *ptr = ZSTR_VAL(s1);
size_t delta = (const char*)s2 - (const char*)s1;
uintptr_t delta = (uintptr_t) s2 - (uintptr_t) s1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question: what was wrong with size_t.
Probably it would be better to use ssize_t (or offset_t).
Now, may be intptr_t is better (I'm not sure).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think size_t is good too. On the x86 platforms they are the same size anyway. I just changed it to match the types of the right hand side without thinking too much about it. I can change it back to size_t.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem. uintptr_t is good as well. (size_t and pointers have the same size, according to some standard).

size_t len = ZSTR_LEN(s1);
zend_ulong ret;

__asm__ (
".LL0%=:\n\t"
"0:\n\t"
"movl (%2,%3), %0\n\t"
"xorl (%2), %0\n\t"
"jne .LL1%=\n\t"
"jne 1f\n\t"
"addl $0x4, %2\n\t"
"subl $0x4, %1\n\t"
"ja .LL0%=\n\t"
"ja 0b\n\t"
"movl $0x1, %0\n\t"
"jmp .LL3%=\n\t"
".LL1%=:\n\t"
"jmp 3f\n\t"
"1:\n\t"
"cmpl $0x4,%1\n\t"
"jb .LL2%=\n\t"
"jb 2f\n\t"
"xorl %0, %0\n\t"
"jmp .LL3%=\n\t"
".LL2%=:\n\t"
"jmp 3f\n\t"
"2:\n\t"
"negl %1\n\t"
"lea 0x20(,%1,8), %1\n\t"
"shll %b1, %0\n\t"
"sete %b0\n\t"
"movzbl %b0, %0\n\t"
".LL3%=:\n"
"3:\n"
: "=&a"(ret),
"+c"(len),
"+r"(ptr)
Expand All @@ -430,32 +430,32 @@ ZEND_API zend_never_inline NOIPA bool ZEND_FASTCALL zend_string_equal_val(const
ZEND_API zend_never_inline NOIPA bool ZEND_FASTCALL zend_string_equal_val(const zend_string *s1, const zend_string *s2)
{
const char *ptr = ZSTR_VAL(s1);
size_t delta = (const char*)s2 - (const char*)s1;
uintptr_t delta = (uintptr_t) s2 - (uintptr_t) s1;
size_t len = ZSTR_LEN(s1);
zend_ulong ret;

__asm__ (
".LL0%=:\n\t"
"0:\n\t"
"movq (%2,%3), %0\n\t"
"xorq (%2), %0\n\t"
"jne .LL1%=\n\t"
"jne 1f\n\t"
"addq $0x8, %2\n\t"
"subq $0x8, %1\n\t"
"ja .LL0%=\n\t"
"ja 0b\n\t"
"movq $0x1, %0\n\t"
"jmp .LL3%=\n\t"
".LL1%=:\n\t"
"jmp 3f\n\t"
"1:\n\t"
"cmpq $0x8,%1\n\t"
"jb .LL2%=\n\t"
"jb 2f\n\t"
"xorq %0, %0\n\t"
"jmp .LL3%=\n\t"
".LL2%=:\n\t"
"jmp 3f\n\t"
"2:\n\t"
"negq %1\n\t"
"lea 0x40(,%1,8), %1\n\t"
"shlq %b1, %0\n\t"
"sete %b0\n\t"
"movzbq %b0, %0\n\t"
".LL3%=:\n"
"3:\n"
: "=&a"(ret),
"+c"(len),
"+r"(ptr)
Expand Down
Loading