laravel / sail

Docker files for running a basic Laravel application.
https://laravel.com/docs/sail
MIT License
1.67k stars 477 forks source link

Segmentation fault using Laravel Sail, Xdebug develop mode and Http::fake #725

Open michiruf opened 3 weeks ago

michiruf commented 3 weeks ago

Sail Version

1.31.3

Laravel Version

11.22.0

PHP Version

8.3.11

Operating System

Windows (WSL)

OS Version

23H2 OS Build 22631.4169

Description

Xdebug Version: 3.3.2 Docker Version: 27.1.1, build 6312585 WSL-Version (wsl --version):

WSL version: 2.2.4.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.61
MSRDC version: 1.2.5326
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26091.1-240325-1447.ge-release
Windows version: 10.0.22631.4169

Hi there, I am currently working on a project, where I stumbled across a segmentation fault, which I then tracked down to be a subset of the combination of the factors sail, xdebug develop mode and throwing a exception inside a Http::fake callback.

After tracking it down as far as I can, I made an example repo with minimal changes to reproduce the issue: https://github.com/michiruf/laravel-sail-xdebug-segmentation-fault

The test that causes the exception can be found here: https://github.com/michiruf/laravel-sail-xdebug-segmentation-fault/blob/master/tests/Feature/SegmentationFaultTest.php and there is also a test.sh that executes the tests 100 times to get a better overview how often this will occur.

Running the tests without laravel sail and without xdebug develop mode (both at once, I unfortunately do not have a php runtime with xdebug on my wsl machine) did not cause the segmentation fault to occur.

In the original project I could work around this issue by introducing a middleware that handles the exceptions for me instead of throwing them in the Http::fake callback, if this information is for any good.

Am I doing something wrong with my laravel sail configuration?

Thanks

Steps To Reproduce

I unfortunately didnt now about laravel new bug-report before starting my test repo, so I started a regular laravel application using the installer.

  1. Checkout the repo under https://github.com/michiruf/laravel-sail-xdebug-segmentation-fault to your WSL machine
  2. Recommended: review the app. In general its a default app with sail configured and exactly one test
  3. Start laravel sail vendor/bin/sail up -d
  4. Perform the test using laravel sail vendor/bin/sail test
  5. Optional: review test.sh and start 100 iterations executing the test.sh in the repo

My last run with 1000 iterations:

Total Runs: 1000
Target Exit Code (1) Occurrences: 505
Target Message ('The process has been signaled with signal "11".') Occurrences: 505
smares commented 1 week ago

It's an Xdebug bug probably as downgrading to Xdebug 3.2.2 worked for us. We're using a custom Dockerfile where we install everything ourselves, though, so not sure how to fix this with Sail.

Edit: By the way, for us it also always happened as soon as there was one breakpoint in the code.