frankenphp icon indicating copy to clipboard operation
frankenphp copied to clipboard

Improve debugging frankenphp documentation to be able to help with debugging a reproducible crash

Open marinhekman opened this issue 2 years ago • 3 comments

Hi, we are still using Symfony Docker without frankenphp in our MSP Challenge project , so I created a branch with frankenphp. We encounter reproducible crashes. See 2 crash call-stacks from the frankenphp log crash1.txt crash2.txt

I would like to help debugging for more information, so could you instruct me how to proceed? So on the contributing page there is some explanation about "Debugging Segmentation Faults in GitHub Actions" . So could you elaborate these steps a bit more ? What do these steps do , what will be the output I could give you here to resolve this issue?

marinhekman avatar Dec 05 '23 16:12 marinhekman

@dunglas or anybody else that knows can reply questions I have about https://github.com/dunglas/frankenphp/blob/main/CONTRIBUTING.md:

  • So if I have a local checkout of dunglas/frankenphp I could do steps 1-3 (editing the .github/workflows/tests.yml). But this would just enable a github test on a new commit/push right ? It does not help debugging a crash locally ?
  • If I do a local checkout , how do I proceed ? Do I need to follow the "Build FrankenPHP images locally" first ? And how do I start an actual container using "docker run" from it?
  • I do not understand what the step 5-8 means, so "Open frankenphp.go"/"Enable cgosymbolizer"/"go get"/"go test". Where do I do this, and what do they do?
  • step 8 "gdb" is actually starting a frankenphp process attached to the gdb debugger I guess? However if you want to debug your own app crashing , I think it would be nice to be able to "start gdb" on all processes until the crash. Is that possible ? At the bare minimum I would like to enable gdb on a single request , like a curl command or something.
  • Maybe add a link how to use gdb
  • Is it possible to use Jetbrains' debugger? Like https://www.jetbrains.com/help/go/attach-to-running-go-processes-with-debugger.html
  • How can we help you to resolve a crash better in general?

Any links for more info will be appreciated as well.

marinhekman avatar Dec 19 '23 09:12 marinhekman

Just running this should be good enough (in the FrankenPHP repo).

docker build -t frankenphp-dev -f dev.Dockerfile .
docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -p 8080:8080 -p 443:443 -v $PWD:/go/src/app -it frankenphp-dev -v /path/to/my/php-app:/php-app

If you want to debug your app, mount it as a volume in the Docker image (as done in the example).

To use GDB, take a look at https://sourceware.org/gdb/current/onlinedocs/gdb.html/. This should look more or less to:

cd /php-app
gdb --args frankenphp run
# Run the request that triggers the crash
bt

You should get a backtrace!

dunglas avatar Dec 21 '23 23:12 dunglas

@dunglas Thanks, I will give it a try .

marinhekman avatar Dec 22 '23 14:12 marinhekman

We now have a dedicated documentation entry: https://frankenphp.dev/docs/contributing/#debugging-segmentation-faults-with-static-builds

dunglas avatar Jun 10 '24 09:06 dunglas

@dunglas do you have any Dockerfile with debug enabled to run a laravel/symfony application? i'm having a segmentation fault using the debian image (running in OSX via Orbstack) after a few simple https requests and trying to debug to send the traces

sneycampos avatar Jun 26 '24 21:06 sneycampos