osx port install of php74 crashes with Illegal instruction: 4
Solution 1:
Here are the important parts:
Exception Codes: KERN_PROTECTION_FAILURE at 0x00007ffeeccd3ff8
VM Regions Near 0x7ffeeccd3ff8:
MALLOC_LARGE 7ff27e800000-7ff27f101000 [ 9220K] rw-/rwx SM=PRV
--> STACK GUARD 7ffee94d4000-7ffeeccd4000 [ 56.0M] ---/rwx SM=NUL stack guard for thread 0
Stack 7ffeeccd4000-7ffeed4d4000 [ 8192K] rw-/rwx SM=ALI thread
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff2035068f __commpage_gettimeofday_internal + 31
1 libsystem_c.dylib 0x00007fff20266b6d gettimeofday + 45
2 libsystem_c.dylib 0x00007fff20282584 time + 48
3 php 0x000000010292db7c tsrm_realpath_r + 384
[...]
503 xdebug.so 0x000000010551e540 xdebug_execute_ex + 1121
504 php 0x000000010295e495 ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER + 405
505 php 0x0000000102942ae7 execute_ex + 35
506 xdebug.so 0x000000010551e540 xdebug_execute_ex + 1121
507 php 0x000000010295e495 ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER + 405
508 php 0x0000000102942ae7 execute_ex + 35509 xdebug.so 0x000000010551e540 xdebug_execute_ex + 1121
510 php 0x000000010295e495 ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER + 405
511 php 0x0000000102942ae7 execute_ex + 35
Notice that you're at exactly 512 (= 2^9) stack frames and the parent frames have been truncated. You're getting a KERN_PROTECTION_FAILURE
at 0x7ffeeccd3ff8
because you've overflowed the maximum stack size and you're trying to write to a protected region (the illegal address is just above Stack
in the STACK GUARD
region, which was created expressly to catch situations like this).
This happened because there was a highly recursive function call chain and it simply exceeded the 512 frame (8192 KB) default stack limit (see ulimit -s
). From the looks of the recursed frames (ZEND_DO_FCALL_SPEC_RETVAL_USED_HANDLER()
over and over), I'd guess that it's php code (either yours or the unit testing framework) which is recursing, rather than the C code of the interpreter itself.
If you aren't sure where the recursion is occurring, one temporary workaround would be to raise the stack limit of the php
process using ulimit(1)
and run your command again in the same Terminal window:
ulimit -s 65532
./phpunit --group Jobs_model
This will run your test with a 64 MB stack limit. Note that the kernel specifies a maximum upper stack limit of 64 MB:
#define DFLSSIZ (8*1024*1024) /* initial stack size limit */
#define MAXSSIZ (64*1024*1024) /* max stack size */
so if your recursion is way huge, you'll still run out of space. At that point, though, you would really want to find out what's recursing so much.