swoole / yasd

Yet Another Swoole Debugger
https://huanghantao.github.io/yasd-wiki/
Apache License 2.0
357 stars 35 forks source link

"php -e" debug with VsCode and Docker Alpine error "Segmentation fault" #174

Closed gitHusband closed 1 year ago

gitHusband commented 2 years ago
  1. What did you do? If possible, provides a simple script and debug step to reproduce the problem.
      1. Start VsCode debug
      1. Start a script php -e
      1. Check the variables by VsCode
      1. Sometimes if you click a variable, the debug was stopped and return error "Segmentation fault"

For example, if you click the args variable, it will return "Segmentation fault" Current File: system/Filters/Filters.php line 163 function $this->initialize(strtolower($uri)); Of CI4 framework v4.2.4 image

  1. What is your machine environment used (show your uname -a & php -v & gcc -v) ?
    $ uname -a
    Linux 2daa3851c92a 5.10.76-linuxkit #1 SMP Mon Nov 8 10:21:19 UTC 2021 x86_64 Linux
# php -v
PHP 7.4.29 (cli) (built: Apr 19 2022 01:09:03) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Yasd v0.3.9-alpha, Our Copyright, by codinghuang
    with Zend OPcache v7.4.29, Copyright (c), by Zend Technologies
# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-alpine-linux-musl/10.3.1/lto-wrapper
Target: x86_64-alpine-linux-musl
Configured with: /home/buildozer/aports/main/gcc/src/gcc-10.3.1_git20211027/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --build=x86_64-alpine-linux-musl --host=x86_64-alpine-linux-musl --target=x86_64-alpine-linux-musl --with-pkgversion='Alpine 10.3.1_git20211027' --enable-checking=release --disable-fixed-point --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers --enable-__cxa_atexit --enable-default-pie --enable-default-ssp --enable-cloog-backend --enable-languages=c,c++,d,objc,go,fortran,ada --disable-libssp --disable-libmpx --disable-libmudflap --disable-libsanitizer --enable-shared --enable-threads --enable-tls --with-system-zlib --with-linker-hash-style=gnu
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.3.1 20211027 (Alpine 10.3.1_git20211027) 
CodeIgniter4: v4.2.4
VsCode: v: 1.70.2
Yasd: Version => 0.3.9-alpha
Swoole: Version => 4.8.9

Here is the log when I click args variable

<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="property_get" transaction_id="18">
  <property type="object" name="this-&gt;request" fullname="this-&gt;request" classname="CodeIgniter\HTTP\CLIRequest" children="1" numchildren="13">
    <property type="array" name="segments" fullname="this-&gt;request-&gt;segments" children="1" numchildren="3"/>
    <property type="array" name="options" fullname="this-&gt;request-&gt;options" children="0" numchildren="0"/>
    <property type="array" name="args" fullname="this-&gt;request-&gt;args" children="1" numchildren="3"/>
    <property type="string" name="method" fullname="this-&gt;request-&gt;method" size="3" encoding="base64">
      <![CDATA[Y2xp]]>
    </property>
    <property type="string" name="proxyIPs" fullname="this-&gt;request-&gt;proxyIPs" size="0" encoding="base64">
      <![CDATA[]]>
    </property>
    <property type="object" name="uri" fullname="this-&gt;request-&gt;uri" classname="CodeIgniter\HTTP\URI" children="1" numchildren="14"/>
    <property type="null" name="protocolVersion" fullname="this-&gt;request-&gt;protocolVersion"/>
    <property type="array" name="validProtocolVersions" fullname="this-&gt;request-&gt;validProtocolVersions" children="1" numchildren="3"/>
    <property type="null" name="body" fullname="this-&gt;request-&gt;body"/>
    <property type="array" name="headers" fullname="this-&gt;request-&gt;headers" children="0" numchildren="0"/>
    <property type="array" name="headerMap" fullname="this-&gt;request-&gt;headerMap" children="0" numchildren="0"/>
    <property type="string" name="ipAddress" fullname="this-&gt;request-&gt;ipAddress" size="0" encoding="base64">
      <![CDATA[]]>
    </property>
    <property type="array" name="globals" fullname="this-&gt;request-&gt;globals" children="1" numchildren="1"/></property>
</response>
property_get -i 19 -d 0 -c 0 -p 0 -n "this->request->args"
huanghantao commented 1 year ago

可以考虑使用 swoole-src的 xdebug分支,https://github.com/swoole/swoole-src/tree/support-xdebug 可以直接使用xdebug进行调试,前提是PHP版本要大于等于8.1