Opened 10 days ago

Last modified 5 days ago

#70987 accepted defect

php80, php81: Segmentation fault when generating phar.php

Reported by: exlemor (Emmanuel Lemor) Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone:
Component: ports Version: 2.10.1
Keywords: sequoia Cc:
Port: php80 php81

Description

Follow-up to ticket #70981...

As requested here is the main.log file to try help figure out how to get php 7.4 working via MacPorts for PHPWebStudy under Mac OS 15 Sequoia.

Sincerely,

Emmanuel.

Attachments (7)

main.log (829.2 KB) - added by exlemor (Emmanuel Lemor) 10 days ago.
main log file as requested.
main-both-commands.log (837.0 KB) - added by exlemor (Emmanuel Lemor) 9 days ago.
Main log file MacPorts PHP74 with both commands
php80.ips (8.4 KB) - added by ryandesign (Ryan Carsten Schmidt) 9 days ago.
php81-0.ips (10.6 KB) - added by ryandesign (Ryan Carsten Schmidt) 9 days ago.
php81-1.ips (8.4 KB) - added by ryandesign (Ryan Carsten Schmidt) 9 days ago.
php81-2.ips (10.6 KB) - added by ryandesign (Ryan Carsten Schmidt) 9 days ago.
php81-3.ips (8.4 KB) - added by ryandesign (Ryan Carsten Schmidt) 9 days ago.

Download all attachments as: .zip

Change History (17)

Changed 10 days ago by exlemor (Emmanuel Lemor)

Attachment: main.log added

main log file as requested.

comment:1 Changed 10 days ago by ryandesign (Ryan Carsten Schmidt)

Owner: set to ryandesign
Status: newassigned

I don't see any signs of -Wno-error=implicit-int in the log so you haven't succeeded in running sudo port install php74 configure.cflags="-Os -Wno-error=implicit-int" after running sudo port clean php74.

Changed 9 days ago by exlemor (Emmanuel Lemor)

Attachment: main-both-commands.log added

Main log file MacPorts PHP74 with both commands

comment:2 Changed 9 days ago by exlemor (Emmanuel Lemor)

I ran both sudo port clean php74 and sudo port install php74 configure.cflags="-Os -Wno-error=implicit-int" and still the same failure...

Please find the new main.log file (called main-both-commands.log) attached.

Sincerely,

Emmanuel.

Last edited 9 days ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:3 Changed 9 days ago by ryandesign (Ryan Carsten Schmidt)

Keywords: sequoia added
Port: php80 added; php74 removed
Status: assignedaccepted
Summary: php74: Undefined Symbolsphp80: Segmentation fault when generating phar.php

The log shows a different failure now—the one I expected to see:

Generating phar.php
/bin/sh: line 1: 55243 Segmentation fault

We see this same problem building php80 on macOS Sequoia, but not php81 or later, and not on earlier macOS versions.

I'll have to investigate why it's crashing when building phar.php.

comment:4 Changed 9 days ago by ryandesign (Ryan Carsten Schmidt)

Can you see if macOS generated a crash log for this crash, probably a crash of the php or php74 process, probably in /Library/Logs/DiagnosticReports, and if so attach it?

comment:5 Changed 9 days ago by ryandesign (Ryan Carsten Schmidt)

Port: php81 added
Summary: php80: Segmentation fault when generating phar.phpphp80, php81: Segmentation fault when generating phar.php

I found the crash reports on the build machine. The crash when building php80 is a little vague to me; it doesn't show the usual stack trace that should tell us what function was running when the problem happened:

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x00000000000001e8
Exception Codes:       0x0000000000000001, 0x00000000000001e8

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [75775]

VM Region Info: 0x1e8 is not in any region.  Bytes before following region: 4509498904
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                      10cc98000-10d683000    [  9.9M] r-x/r-x SM=COW  /opt/local/var/macports/*/php

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   ???                           	             0x1e8 ???


Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x00007fd29780c900  rbx: 0x000000010e205000  rcx: 0x0000000000000003  rdx: 0x000000010e205020
  rdi: 0x000000010e205000  rsi: 0x000000010e200000  rbp: 0x000000000000001a  rsp: 0x00007ff7b3266be0
   r8: 0x000000010e205000   r9: 0x000000000000006c  r10: 0x00000000001ff800  r11: 0x0000000000000030
  r12: 0x0000000000000000  r13: 0x000000010d6989c0  r14: 0x00007ff7b3266c00  r15: 0x000000010ce78ecd
  rip: 0x00000000000001e8  rfl: 0x0000000000010202  cr2: 0x00000000000001e8
  
Logical CPU:     0
Error Code:      0x00000014 (no mapping for user instruction read)
Trap Number:     14

But there were four more crash logs from the build of php81. I now realize generating phar.php also crashes when building php81 on macOS 15, but unlike with php80 and earlier it doesn't stop the build. Two of the crashes are segmentation faults and the logs look like the one from php80. The other two crashes are abort traps and their logs more helpfully point to a function—zend_hash_find or rather the unnamed label .LL31 that zend_hash_find calls:

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000

Termination Reason:    Namespace SIGNAL, Code 6 Abort trap: 6
Terminating Process:   php [40488]

Application Specific Information:
abort() called


Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	    0x7ff813d7db52 __pthread_kill + 10
1   libsystem_pthread.dylib       	    0x7ff813db7f85 pthread_kill + 262
2   libsystem_c.dylib             	    0x7ff813cd8b19 abort + 126
3   libsystem_malloc.dylib        	    0x7ff813bd7ab1 malloc_vreport + 857
4   libsystem_malloc.dylib        	    0x7ff813bdb58b malloc_report + 151
5   php                           	       0x10cf5e27d .LL31 + 203
6   php                           	       0x10cef6498 zend_hash_find + 128
7   php                           	       0x10cf752b1 lookup_class_ex + 312
8   php                           	       0x10cf70823 zend_perform_covariant_type_check + 885
9   php                           	       0x10cf75ae8 zend_do_perform_implementation_check + 554
10  php                           	       0x10cf755f8 do_inheritance_check_on_method + 344
11  php                           	       0x10cf722df do_interface_implementation + 520
12  php                           	       0x10ceec276 zend_class_implements + 216
13  php                           	       0x10cf5d6fd zend_register_weakref_ce + 316
14  php                           	       0x10cf703be zend_register_default_classes + 34
15  php                           	       0x10cef7ba5 zm_startup_core + 101
16  php                           	       0x10cee9ff9 zend_startup_module_ex + 259
17  php                           	       0x10ceea38f zend_startup_module_zval + 12
18  php                           	       0x10cef55cd zend_hash_apply + 87
19  php                           	       0x10ce87a9c php_module_startup + 2180
20  php                           	       0x10cfbb90d php_cli_startup + 13
21  php                           	       0x10cfb9666 main + 1356
22  dyld                          	    0x7ff813a2a2cd start + 1805


Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x0000000000000006  rcx: 0x00007ff7b3203dc8  rdx: 0x0000000000000000
  rdi: 0x0000000000000103  rsi: 0x0000000000000006  rbp: 0x00007ff7b3203df0  rsp: 0x00007ff7b3203dc8
   r8: 0x000000000000002e   r9: 0x0000000000000000  r10: 0x0000000000000000  r11: 0x0000000000000246
  r12: 0x0000000000000000  r13: 0x0000000000000050  r14: 0x0000000000000103  r15: 0x0000000000000016
  rip: 0x00007ff813d7db52  rfl: 0x0000000000000246  cr2: 0x0000000000000000
  
Logical CPU:     0
Error Code:      0x02000148 
Trap Number:     133

I don't know what phar.php is, why it is being generated, or what it is used for. It does not, for example, as far as I can tell, get installed.

Would you try installing the php81, php82, and php83 ports and running php81 -v, php82 -v, and php83 -v? I believe php81 will crash but hope php82 and php83 don't. This would help determine if we're looking for an existing fix in php82 that we can backport or something new that still needs to have a fix developed.

Changed 9 days ago by ryandesign (Ryan Carsten Schmidt)

Attachment: php80.ips added

Changed 9 days ago by ryandesign (Ryan Carsten Schmidt)

Attachment: php81-0.ips added

Changed 9 days ago by ryandesign (Ryan Carsten Schmidt)

Attachment: php81-1.ips added

Changed 9 days ago by ryandesign (Ryan Carsten Schmidt)

Attachment: php81-2.ips added

Changed 9 days ago by ryandesign (Ryan Carsten Schmidt)

Attachment: php81-3.ips added

comment:6 in reply to:  4 ; Changed 8 days ago by exlemor (Emmanuel Lemor)

Replying to ryandesign:

Can you see if macOS generated a crash log for this crash, probably a crash of the php or php74 process, probably in /Library/Logs/DiagnosticReports, and if so attach it?

Gladly, but what would that log file have for a name - lots of files in that folder structure :/

Sincerely,

Emmanuel

comment:7 in reply to:  5 Changed 8 days ago by exlemor (Emmanuel Lemor)

Replying to ryandesign:

I found the crash reports on the build machine. The crash when building php80 is a little vague to me; it doesn't show the usual stack trace that should tell us what function was running when the problem happened:

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x00000000000001e8
Exception Codes:       0x0000000000000001, 0x00000000000001e8

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [75775]

VM Region Info: 0x1e8 is not in any region.  Bytes before following region: 4509498904
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                      10cc98000-10d683000    [  9.9M] r-x/r-x SM=COW  /opt/local/var/macports/*/php

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   ???                           	             0x1e8 ???


Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x00007fd29780c900  rbx: 0x000000010e205000  rcx: 0x0000000000000003  rdx: 0x000000010e205020
  rdi: 0x000000010e205000  rsi: 0x000000010e200000  rbp: 0x000000000000001a  rsp: 0x00007ff7b3266be0
   r8: 0x000000010e205000   r9: 0x000000000000006c  r10: 0x00000000001ff800  r11: 0x0000000000000030
  r12: 0x0000000000000000  r13: 0x000000010d6989c0  r14: 0x00007ff7b3266c00  r15: 0x000000010ce78ecd
  rip: 0x00000000000001e8  rfl: 0x0000000000010202  cr2: 0x00000000000001e8
  
Logical CPU:     0
Error Code:      0x00000014 (no mapping for user instruction read)
Trap Number:     14

But there were four more crash logs from the build of php81. I now realize generating phar.php also crashes when building php81 on macOS 15, but unlike with php80 and earlier it doesn't stop the build. Two of the crashes are segmentation faults and the logs look like the one from php80. The other two crashes are abort traps and their logs more helpfully point to a function—zend_hash_find or rather the unnamed label .LL31 that zend_hash_find calls:

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000

Termination Reason:    Namespace SIGNAL, Code 6 Abort trap: 6
Terminating Process:   php [40488]

Application Specific Information:
abort() called


Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	    0x7ff813d7db52 __pthread_kill + 10
1   libsystem_pthread.dylib       	    0x7ff813db7f85 pthread_kill + 262
2   libsystem_c.dylib             	    0x7ff813cd8b19 abort + 126
3   libsystem_malloc.dylib        	    0x7ff813bd7ab1 malloc_vreport + 857
4   libsystem_malloc.dylib        	    0x7ff813bdb58b malloc_report + 151
5   php                           	       0x10cf5e27d .LL31 + 203
6   php                           	       0x10cef6498 zend_hash_find + 128
7   php                           	       0x10cf752b1 lookup_class_ex + 312
8   php                           	       0x10cf70823 zend_perform_covariant_type_check + 885
9   php                           	       0x10cf75ae8 zend_do_perform_implementation_check + 554
10  php                           	       0x10cf755f8 do_inheritance_check_on_method + 344
11  php                           	       0x10cf722df do_interface_implementation + 520
12  php                           	       0x10ceec276 zend_class_implements + 216
13  php                           	       0x10cf5d6fd zend_register_weakref_ce + 316
14  php                           	       0x10cf703be zend_register_default_classes + 34
15  php                           	       0x10cef7ba5 zm_startup_core + 101
16  php                           	       0x10cee9ff9 zend_startup_module_ex + 259
17  php                           	       0x10ceea38f zend_startup_module_zval + 12
18  php                           	       0x10cef55cd zend_hash_apply + 87
19  php                           	       0x10ce87a9c php_module_startup + 2180
20  php                           	       0x10cfbb90d php_cli_startup + 13
21  php                           	       0x10cfb9666 main + 1356
22  dyld                          	    0x7ff813a2a2cd start + 1805


Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x0000000000000006  rcx: 0x00007ff7b3203dc8  rdx: 0x0000000000000000
  rdi: 0x0000000000000103  rsi: 0x0000000000000006  rbp: 0x00007ff7b3203df0  rsp: 0x00007ff7b3203dc8
   r8: 0x000000000000002e   r9: 0x0000000000000000  r10: 0x0000000000000000  r11: 0x0000000000000246
  r12: 0x0000000000000000  r13: 0x0000000000000050  r14: 0x0000000000000103  r15: 0x0000000000000016
  rip: 0x00007ff813d7db52  rfl: 0x0000000000000246  cr2: 0x0000000000000000
  
Logical CPU:     0
Error Code:      0x02000148 
Trap Number:     133

I don't know what phar.php is, why it is being generated, or what it is used for. It does not, for example, as far as I can tell, get installed.

Would you try installing the php81, php82, and php83 ports and running php81 -v, php82 -v, and php83 -v? I believe php81 will crash but hope php82 and php83 don't. This would help determine if we're looking for an existing fix in php82 that we can backport or something new that still needs to have a fix developed.

Actually MacPorts php8.1 installed fine it seems (no errors at the end)... I am actually running MacPorts through PHPWebStudy (and PHPPWebStudy also has built-in PHP 8.1 - 8.3 capabilities or MacPorts - I used MacPorts integration and chose php 8.1 and that installed ) -- at least it says installed successfully - not sure if it did or not and then installed MySQL 8.0.x without issue...

Unfortunately, I need PHP 7.4 and not PHP 8 or newer ;(

Sincerely,

Emmanuel.

comment:8 in reply to:  6 Changed 8 days ago by ryandesign (Ryan Carsten Schmidt)

Replying to exlemor:

Replying to ryandesign:

Can you see if macOS generated a crash log for this crash, probably a crash of the php or php74 process, probably in /Library/Logs/DiagnosticReports, and if so attach it?

Gladly, but what would that log file have for a name - lots of files in that folder structure :/

The log file name starts with the name of the executable (php) followed by a date and time and ending with .ips. Less urgent now that I found the crash logs on the build machine; I bet yours say more or less the same thing.

Replying to exlemor:

Actually MacPorts php8.1 installed fine it seems (no errors at the end)...

Right, we saw that on our build machine as well, but the question was whether it works or not, and I suspected that it does not. I have now installed php81, php82, and php83 on another machine with macOS 15 using binaries from our build machine and php81 -v crashes while php82 -v and php83 -v work correctly. I then rebuilt php81 from source on that machine and it still crashes.

Unfortunately, I need PHP 7.4 and not PHP 8 or newer ;(

Right, but now that we know the problem exists in php81 and older and is solved in php82 that helps narrow the focus of where we need to look for the fix. It also gives me enough information to file a bug report with the developers of php. They might not have been interested in helping us with problems with php80 or older since those versions have already reached end of life, but php81 is not dead yet so they may help us.

comment:9 Changed 6 days ago by ryandesign (Ryan Carsten Schmidt)

In the upstream bug report I have identified the commit that fixed the problem in php 8.2.16 and that backporting it to 8.1.30 fixes the crash. Backporting to 8.0.x and earlier will be more complicated.

comment:10 Changed 5 days ago by exlemor (Emmanuel Lemor)

I have faith you can squeeze out a solution for us poor souls in need of PHP 7.4 ;) (hug) lol

Note: See TracTickets for help on using tickets.