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

Since v1.1.5 frankenphp crash on laravel 11 project #1346

Open
XternalSoft opened this issue Jan 21, 2025 · 9 comments
Open

Since v1.1.5 frankenphp crash on laravel 11 project #1346

XternalSoft opened this issue Jan 21, 2025 · 9 comments
Labels
bug Something isn't working

Comments

@XternalSoft
Copy link

XternalSoft commented Jan 21, 2025

What happened?

Hello,

Since version 1.1.5, FrankenPHP has been consistently crashing when used with a Laravel 11 project. The crash occurs immediately upon the first page load attempt.

See below the crash debug

Build Type

Official static build

Worker Mode

Yes

Operating System

GNU/Linux

CPU Architecture

x86_64

PHP configuration

No specific php configuration

Relevant log output

PID: 979391 (frankenphp)
           UID: 1011 (xxx)
           GID: 1011 (xxx)
        Signal: 4 (ILL)
     Timestamp: Tue 2025-01-21 18:26:05 CET (1min 49s ago)
  Command Line: frankenphp run Caddyfile
    Executable: /usr/sbin/frankenphp
 Control Group: /user.slice/user-1011.slice/session-226500.scope
          Unit: session-226500.scope
         Slice: user-1011.slice
       Session: 226500
     Owner UID: 1011 (xxx)
       Boot ID: 97d108e50960432d84dd56ca1a597cbc
    Machine ID: 9bba94b985ae4fbcb10432433d6434e5
      Hostname: xxx
       Storage: /var/lib/systemd/coredump/core.frankenphp.1011.97d108e50960432d84dd56ca1a597cbc.979391.1737480365000000.zst (present)
  Size on Disk: 86.6M
       Message: Process 979391 (frankenphp) of user 1011 dumped core.
                
                Stack trace of thread 979419:
                #0  0x00007fdb7b04b341 runtime.raise (/usr/sbin/frankenphp + 0x84b341)
                #1  0x00007fdb7b01f66d runtime.raisebadsignal (/usr/sbin/frankenphp + 0x81f66d)
                #2  0x00007fdb7b01fae7 runtime.badsignal (/usr/sbin/frankenphp + 0x81fae7)
                #3  0x00007fdb7b01e65b runtime.sigtrampgo (/usr/sbin/frankenphp + 0x81e65b)
                #4  0x00007fdb7b04b649 runtime.sigtramp (/usr/sbin/frankenphp + 0x84b649)
                #5  0x00007fdb7e110a0a n/a (/usr/sbin/frankenphp + 0x3910a0a)
                ELF object binary architecture: AMD x86-64

GNU gdb (Rocky Linux) 14.2-3.el9
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/sbin/frankenphp...

warning: Can't open file /dev/zero (deleted) during file-backed mapping note processing
[New LWP 979419]
[New LWP 979395]
[New LWP 979394]
[New LWP 979393]
[New LWP 979392]
[New LWP 979391]
[New LWP 979396]
[New LWP 979422]
[New LWP 979418]
[New LWP 979404]
[New LWP 979411]
[New LWP 979399]
[New LWP 979398]
[New LWP 979410]
[New LWP 979415]
[New LWP 979414]
[New LWP 979412]
[New LWP 979400]
[New LWP 979420]
[New LWP 979413]
[New LWP 979416]
[New LWP 979401]
[New LWP 979402]
[New LWP 979417]
[New LWP 979405]
[New LWP 979397]
[New LWP 979403]
[New LWP 979409]
[New LWP 979421]
--Type <RET> for more, q to quit, c to continue without paging--
[New LWP 979406]
[New LWP 979408]
[New LWP 979407]
Core was generated by `frankenphp run Caddyfile'.
Program terminated with signal SIGILL, Illegal instruction.
#0  runtime.raise () at /usr/local/go/src/runtime/sys_linux_amd64.s:154
154             RET
[Current thread is 1 (LWP 979419)]
Loading Go Runtime support.
(gdb) bt full
#0  runtime.raise () at /usr/local/go/src/runtime/sys_linux_amd64.s:154
No locals.
#1  0x00007fdb7b01f66d in runtime.raisebadsignal (sig=4, c=0xc000725a50) at /usr/local/go/src/runtime/signal_unix.go:1030
        handler = 0
        flags = <optimized out>
#2  0x00007fdb7b01fae7 in runtime.badsignal (sig=4, c=0xc000725a50) at /usr/local/go/src/runtime/signal_unix.go:1139
No locals.
#3  0x00007fdb7b01e65b in runtime.sigtrampgo (sig=4, info=0xc000725bf0, ctx=0xc000725ac0) at /usr/local/go/src/runtime/signal_unix.go:468
        c = <optimized out>
        gp = 0xc000684e00
        setStack = <optimized out>
        gsignalStack = <optimized out>
#4  0x00007fdb7b04b649 in runtime.sigtramp () at /usr/local/go/src/runtime/sys_linux_amd64.s:352
No locals.
#5  <signal handler called>
No locals.
#6  0x00007fdb7ec894a0 in __gmpn_set_str ()
No symbol table info available.
#7  0x00007fdb7ec80f1a in __gmpz_set_str ()
No symbol table info available.
#8  0x00007fdb7d58aecc in convert_zstr_to_gmp (gmp_number=0x7fdb2fd802e0, val=0x7fdb17d8b2d0, base=0, arg_pos=1)
    at /go/src/app/dist/static-php-cli/source/php-src/ext/gmp/gmp.c:673
        num_str = 0x7fdb17d8b2e8 "173748036553432"
        skip_lead = false
        num_len = 15
        gmp_ret = 32731
#9  0x00007fdb7d58af9f in convert_to_gmp (gmpnumber=0x7fdb2fd802e0, val=0x7fdb2e016250, base=0, arg_pos=1)
    at /go/src/app/dist/static-php-cli/source/php-src/ext/gmp/gmp.c:695
No locals.
#10 0x00007fdb7d58d475 in zif_gmp_strval (execute_data=0x7fdb2e016200, return_value=0x7fdb2e0161f0)
    at /go/src/app/dist/static-php-cli/source/php-src/ext/gmp/gmp.c:1143
        gmpnumber_arg = 0x7fdb2e016250
        base = 16
        gmpnum = 0x7fdb2e016180
        temp_a = {num = {{_mp_alloc = 2, _mp_size = 0, _mp_d = 0x7fdb2c41acb0}}, is_used = false}
#11 0x00007fdb7d280305 in ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER () at /go/src/app/dist/static-php-cli/source/php-src/Zend/zend_vm_execute.h:1351
        call = 0x7fdb2e016200
        fbc = 0x7fdb332e9020
        ret = 0x7fdb2e0161f0
        retval = {value = {lval = 140578574565376, dval = 6.9455044234084328e-310, counted = 0x7fdb00000000, str = 0x7fdb00000000, 
            arr = 0x7fdb00000000, obj = 0x7fdb00000000, res = 0x7fdb00000000, ref = 0x7fdb00000000, ast = 0x7fdb00000000, zv = 0x7fdb00000000, 
            ptr = 0x7fdb00000000, ce = 0x7fdb00000000, func = 0x7fdb00000000, ww = {w1 = 0, w2 = 32731}}, u1 = {type_info = 3, v = {type = 3 '\003', 
              type_flags = 0 '\000', u = {extra = 0}}}, u2 = {next = 32731, cache_slot = 32731, opline_num = 32731, lineno = 32731, num_args = 32731, 
            fe_pos = 32731, fe_iter_idx = 32731, guard = 32731, constant_flags = 32731, extra = 32731}}
        call_info = 0
--Type <RET> for more, q to quit, c to continue without paging--
#12 execute_ex (ex=0x7fdb2e014200) at /go/src/app/dist/static-php-cli/source/php-src/Zend/zend_vm_execute.h:58809
        vm_stack_data = {
          hybrid_jit_red_zone = "@\000\000.\333\177\000\000PU\t\000\000\000\000\000\200\235\005.\333\177\000\000\000D\330/\333\177\000\0008P\t.\333\177\000\000\000B\001.\333\177\000", orig_opline = 0x41d674a0, orig_execute_data = 0x7fdb2e0140a0}
#13 0x00007fdb7d14a292 in zend_call_function (fci=0x7fdb2fd84440, fci_cache=0x7fdb2fd84410)
    at /go/src/app/dist/static-php-cli/source/php-src/Zend/zend_execute_API.c:1000
        orig_jit_trace_num = 0
        i = 0
        call = 0x7fdb2e014200
        fci_cache_local = {function_handler = 0x41d674a0, calling_scope = 0x0, called_scope = 0x7fdb2fd84370, 
          object = 0x7fdb7cfd169b <go_frankenphp_worker_handle_request_start+111>, closure = 0x7fdb2fd84370}
        func = 0x7fdb2e095038
        call_info = 33685504
        object_or_called_scope = 0x0
        orig_fake_scope = 0x0
#14 0x00007fdb7cfd4845 in zif_frankenphp_handle_request (execute_data=0x7fdb2e0141a0, return_value=0x7fdb2e014170) at frankenphp.c:432
        fci = {size = 64, function_name = {value = {lval = 140579346927616, dval = 6.9455425831733257e-310, counted = 0x7fdb2e095000, 
              str = 0x7fdb2e095000, arr = 0x7fdb2e095000, obj = 0x7fdb2e095000, res = 0x7fdb2e095000, ref = 0x7fdb2e095000, ast = 0x7fdb2e095000, 
              zv = 0x7fdb2e095000, ptr = 0x7fdb2e095000, ce = 0x7fdb2e095000, func = 0x7fdb2e095000, ww = {w1 = 772362240, w2 = 32731}}, u1 = {
              type_info = 776, v = {type = 8 '\b', type_flags = 3 '\003', u = {extra = 0}}}, u2 = {next = 2127, cache_slot = 2127, opline_num = 2127, 
              lineno = 2127, num_args = 2127, fe_pos = 2127, fe_iter_idx = 2127, guard = 2127, constant_flags = 2127, extra = 2127}}, 
          retval = 0x7fdb2fd84400, params = 0x0, object = 0x0, param_count = 0, named_params = 0x0}
        fcc = {function_handler = 0x7fdb2e095038, calling_scope = 0x0, called_scope = 0x0, object = 0x0, closure = 0x7fdb2e095000}
        ctx = 0x7fdb2e380c30
        request = true
        retval = {value = {lval = 0, dval = 0, counted = 0x0, str = 0x0, arr = 0x0, obj = 0x0, res = 0x0, ref = 0x0, ast = 0x0, zv = 0x0, ptr = 0x0, 
            ce = 0x0, func = 0x0, ww = {w1 = 0, w2 = 0}}, u1 = {type_info = 0, v = {type = 0 '\000', type_flags = 0 '\000', u = {extra = 0}}}, u2 = {
            next = 0, cache_slot = 0, opline_num = 0, lineno = 0, num_args = 0, fe_pos = 0, fe_iter_idx = 0, guard = 0, constant_flags = 0, extra = 0}}
#15 0x00007fdb7d280305 in ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER () at /go/src/app/dist/static-php-cli/source/php-src/Zend/zend_vm_execute.h:1351
        call = 0x7fdb2e0141a0
        fbc = 0x7fdb33339850
        ret = 0x7fdb2e014170
        retval = {value = {lval = 140578574565376, dval = 6.9455044234084328e-310, counted = 0x7fdb00000000, str = 0x7fdb00000000, 
            arr = 0x7fdb00000000, obj = 0x7fdb00000000, res = 0x7fdb00000000, ref = 0x7fdb00000000, ast = 0x7fdb00000000, zv = 0x7fdb00000000, 
            ptr = 0x7fdb00000000, ce = 0x7fdb00000000, func = 0x7fdb00000000, ww = {w1 = 0, w2 = 32731}}, u1 = {type_info = 3, v = {type = 3 '\003', 
              type_flags = 0 '\000', u = {extra = 0}}}, u2 = {next = 1, cache_slot = 1, opline_num = 1, lineno = 1, num_args = 1, fe_pos = 1, 
            fe_iter_idx = 1, guard = 1, constant_flags = 1, extra = 1}}
        call_info = 0
#16 execute_ex (ex=0x7fdb2e014020) at /go/src/app/dist/static-php-cli/source/php-src/Zend/zend_vm_execute.h:58809
        vm_stack_data = {
          hybrid_jit_red_zone = "@\000\000.\333\177\000\000\020\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000@\000\000.\333\177\000\000Hq\005\000\000\000\000\000 y\006\000\000\000\000", orig_opline = 0x7fdb33910b30, orig_execute_data = 0x7fdb339104d0}
#17 0x00007fdb7d29e8b6 in zend_execute (op_array=0x7fdb2e06d000, return_value=0x0)
    at /go/src/app/dist/static-php-cli/source/php-src/Zend/zend_vm_execute.h:64236
        execute_data = 0x7fdb2e014020
--Type <RET> for more, q to quit, c to continue without paging--
        object_or_called_scope = 0x0
        call_info = 1245184
#18 0x00007fdb7d3837e4 in zend_execute_script (type=8, retval=0x0, file_handle=0x7fdb2fd8a540)
    at /go/src/app/dist/static-php-cli/source/php-src/Zend/zend.c:1934
        op_array = 0x7fdb2e06d000
        ret = SUCCESS
#19 0x00007fdb7d078249 in php_execute_script_ex (primary_file=0x7fdb2fd8a540, retval=0x0)
    at /go/src/app/dist/static-php-cli/source/php-src/main/main.c:2591
        realfile = "\000\000\000B\000\000\000\0000\000\000\000\001\000\000\000\006", '\000' <repeats 11 times>, "\001\000\000\000\001", '\000' <repeats 15 times>, "<z\022\201\333\177\000\000\300\236\330/\333\177\000\000Д\330/\333\177\000\000\230E\346.\333\177\000\000Pԓ\203\333\177\000\000\300\236\330/\333\177\000\000\343\236\330/\333\177\000\000\350\224\330/\333\177\000\0000", '\000' <repeats 15 times>, "\300\236\330/\333\177\000\000\345\236\330/\333\177\000\000Pԓ\203\333\177\000\000<z\022\201\333\177\000\000\000\225\330/\333\177\000\000(\237\330/\333\177\000\000\300\225\330/\333\177\000\000\277\263\362}\333\177\000\000(\000\000\000\000\000\000\000(\237\330"...
        __orig_bailout = 0x7fdb2fd8a590
        __bailout = {{__jb = {140579349990400, 140579377292528, 536576, 140579377293080, 140579439707344, 140579439708976, 140579377283568, 
              140580672208303}, __fl = 140580802311032, __ss = {88, 140579361408440, 140579355208560, 0, 140579377290944, 140579361408408, 
              140580740037608, 140580740037180, 140579377288448, 140579377290981, 140579377290944, 140579377288224, 140580687626298, 140580687670757, 
              0, 140579377290973}}}
        prepend_file_p = 0x0
        append_file_p = 0x0
        prepend_file = {handle = {fp = 0x7fdb803ed32b, stream = {handle = 0x7fdb803ed32b, isatty = 802722496, reader = 0x5, 
              fsizer = 0x7fdb81127a3c <google_protobuf_FeatureSet__fields+60>, closer = 0x7fdb2fd892f0}}, 
          filename = 0x7fdb7df2c3ce <_upb_MiniTableField_HasbitMask_dont_copy_me__upb_internal_use_only+24>, opened_path = 0x0, type = 60 '<', 
          primary_script = 122, in_list = 18, buf = 0x100000000 <error: Cannot access memory at address 0x100000000>, len = 69}
        append_file = {handle = {fp = 0x7fdb2fd89320, stream = {handle = 0x7fdb2fd89320, isatty = 2113067879, 
              reader = 0x7fdb81127a3c <google_protobuf_FeatureSet__fields+60>, fsizer = 0x7fdb2ee64598, closer = 0x2000000000000007}}, filename = 0x8, 
          opened_path = 0x7fdb2fd894a0, type = 224 '\340', primary_script = 132, in_list = 244, buf = 0x7fdb2fd89500 "\001", len = 140580740037180}
        old_cwd = 0x7fdb2fd881f0 "/home/sites/web/xxx"
        use_heap = false
        result = true
#20 0x00007fdb7d078453 in php_execute_script (primary_file=0x7fdb2fd8a540) at /go/src/app/dist/static-php-cli/source/php-src/main/main.c:2631
No locals.
#21 0x00007fdb7cfd63c8 in frankenphp_execute_script (file_name=0xc00063eb90 "/home/sites/web/xxx/public/frankenphp-worker.php")
    at frankenphp.c:1024
        __orig_bailout = 0x0
        __bailout = {{__jb = {140579349990400, 140579377292896, 536576, 140579377293080, 140579439707344, 140579439708976, 140579377292576, 
              140580671546265}, __fl = 140579377292864, __ss = {0, 140579377292816, 140580671551192, 140579377293080, 0, 140579439708976, 0, 
              140579377292896, 140580671526152, 2, 1, 140579377292896, 0, 1, 824640269200, 140579377293080}}}
        status = 0
        file_handle = {handle = {fp = 0x7fdb2e0600e0, stream = {handle = 0x7fdb2e0600e0, isatty = 0, reader = 0x7fdb7d09cca4 <_php_stream_read>, 
              fsizer = 0x7fdb7d075e46 <php_zend_stream_fsizer>, closer = 0x7fdb7d075e26 <php_zend_stream_closer>}}, filename = 0x7fdb2e05d000, 
          opened_path = 0x7fdb2e05d0c0, type = 2 '\002', primary_script = false, in_list = true, 
          buf = 0x7fdb2e063000 "<?php\n\ndeclare(strict_types=1);\n// Set a default for the application base path and public path if they are missing...\n$_SERVER['APP_BASE_PATH'] = $_ENV['APP_BASE_PATH'] ?? $_SERVER['APP_BASE_PATH'] ??"..., len = 385}
#22 0x00007fdb7cfd601d in php_thread (arg=0x1) at frankenphp.c:898
--Type <RET> for more, q to quit, c to continue without paging--
        thread_name = "php-1\000\000\000\000\000\000\000\000\000\000"
        default_filter = 0x0
        scriptName = 0xc00063eb90 "/home/sites/web/xxx/public/frankenphp-worker.php"
#23 0x00007fdb7e118676 in start (p=0x7fdb2fd8a6f8) at src/thread/pthread_create.c:207
        args = 0x7fdb2fd8a6f8
        state = <optimized out>
#24 0x00007fdb7e119e81 in __clone () at src/thread/x86_64/clone.s:22
No locals.

It appears that the crash is coming from the gmp extension

@XternalSoft XternalSoft added the bug Something isn't working label Jan 21, 2025
@XternalSoft XternalSoft changed the title Since v1.1.5 frankenphp crash on Since v1.1.5 frankenphp crash on laravel 11 project Jan 21, 2025
@AlliBalliBaba
Copy link
Collaborator

Does this only happen on 1.1.5 or also on the newest version (1.4.1) ? What is the original gmp call that causes the crashing? The extensions seems to work on a simple hello world for me, at least in the Debian Docker iamges echo gmp_strval("000100", 10);

@XternalSoft
Copy link
Author

Since 1.1.5, and happen only on my server, not on my local machine.

@XternalSoft
Copy link
Author

On my server, I just created a new Laravel 11 project. Frankenphp doesn't crash... so this means that it's the code loading in my project that's causing this crash... maybe a vendor... the search is going to be difficult..

@XternalSoft
Copy link
Author

Oooooh

If I add your code @AlliBalliBaba in "/" route (see in screenshot) franken crash..

Image

@AlliBalliBaba
Copy link
Collaborator

And locally you're using Ubuntu, but the server is running on Rocky Linux? I'd usually expect the static binary to be compatible with all Linux x86_64 distributions, but that might not be the case? @dunglas

I think what you could also try is building the static binary directly on the server according to this instruction.

@XternalSoft
Copy link
Author

Locally I'm on Fedora.
Okay, I'll try to do a static build from the server.

@dunglas
Copy link
Owner

dunglas commented Jan 23, 2025

In theory this should be compatible with all servers but it's just theory...

@withinboredom
Copy link
Collaborator

The issue could be that your kernel is older on your server? A static build usually uses the "latest" syscall maps in libc, and on an older kernel, it may not support newer syscalls. A custom build on the machine itself will use the system's libc and compile in a real syscall table that is actually supported.

I'm not saying that is the issue, but seeing as that it is gmp which does some syscall and/or cpu extension stuff, it is possibly a kernel/cpu support issue.

@withinboredom
Copy link
Collaborator

@dunglas -- it might be a compile-time issue as well in the static builder. Generally ./configure will detect cpu-specific optimizations and it is possible that our CI has some specific cpu optimizations being compiled in. Generally, it would be compiled to be "generic" so it could work on any machine, at the expense of performance. It could be something silly in @XternalSoft's case, where his cpu is lacking SSE2, AVX2, BMI2, or something while it was compiled with those optimizations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants