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

Http fake call returning exception causes SIGSEV with XDebug enabled #51046

Closed
1 of 2 tasks
eleftrik opened this issue Apr 13, 2024 · 8 comments
Closed
1 of 2 tasks

Http fake call returning exception causes SIGSEV with XDebug enabled #51046

eleftrik opened this issue Apr 13, 2024 · 8 comments

Comments

@eleftrik
Copy link

eleftrik commented Apr 13, 2024

Laravel Version

11.3.1

PHP Version

8.3.6

Database Driver & Version

No response

Description

Laravel 11 brand new application (same behavior with Laravel 10).

The following test

<?php

use Illuminate\Support\Facades\Http;

it('should throw an Exception', function () {
    Http::fake([
        '*' => fn () => throw new Exception()
    ]);

    expect(fn () => Http::get('www.example.com'))
        ->toThrow(Exception::class);
});
  • passes with XDebug disabled
  • does not pass with XDebug enabled, returning Process finished with exit code 139 (interrupted by signal 11:SIGSEGV).

php.ini configuration:

memory_limit=512M
upload_max_filesize=2M

; XDebug
xdebug.mode=develop,coverage
zend_extension=/Applications/Herd.app/Contents/Resources/xdebug/xdebug-83-x86.so

Sorry, I don't know if it's related to Laravel or is more about Pest / PHPUnit. Could be related to sebastianbergmann/phpunit#5809?

I have a couple of Laravel 10/11 applications with a bunch of similar tests (the one above is a simplified example) and they passed without problems, until a couple of weeks ago.

I could disable XDebug, but I need it enabled to run code coverage.

Thank you for any hints.

Steps To Reproduce

laravel new test --pest --no-interaction

# write the above test

# enable XDebug

php artisan test
@driesvints
Copy link
Member

until a couple of weeks ago.

Could you maybe pinpoint the exact PHP, Laravel, PHPUnit or Pest version that introduces this issue?

@eleftrik
Copy link
Author

until a couple of weeks ago.

Could you maybe pinpoint the exact PHP, Laravel, PHPUnit or Pest version that introduces this issue?

Hi @driesvints, thanks for the feedback.
I don't know exactly which version introduced this issue. I can report versions I'm experiencing this issue with:

PHP: 8.3.6
Laravel: 11.3.1 / 10.48.7
Pest: 2.34.7
XDebug: 3.3.1

Please let me know if I answered what you need.

Thanks

@driesvints
Copy link
Member

What versions did you come from? You specifically mention the issue only popped up in recent weeks. Which versions were you at before that?

@eleftrik
Copy link
Author

@driesvints I checked out my codebase to old commits, but the issue is still happening, so I don't know who the culprit is...

I just tried to use PHP 8.3.6 + XDebug 3.3.2 (just release, I think), but the segmentation fault issue is still happening.
I'm sorry, I can't provide further useful details.

Anyway, it should be possible to reproduce the issue as I reported.
Are you able to run that test with XDebug enabled in a Laravel brand new application?
I'm using Herd 1.6.0 with its bundled XDebug.

Thanks

@eleftrik
Copy link
Author

@driesvints Upon further investigation, I found the exact place where problems start only when XDebug is enabled (but I don't know why):

vendor/guzzlehttp/guzzle/src/Client.php - line 333

        try {
            return P\Create::promiseFor($handler($request, $options)); // <----------- here something causes infinite recursion?
        } catch (\Exception $e) {
            return P\Create::rejectionFor($e);
        }

@driesvints
Copy link
Member

@eleftrik I found this which seems similar: guzzle/guzzle#942

Can you change xdebug.remote_autostart=0 in your php.ini and try again?

@eleftrik
Copy link
Author

@eleftrik I found this which seems similar: guzzle/guzzle#942

Can you change xdebug.remote_autostart=0 in your php.ini and try again?

xdebug.remote_autostart=0 didn't solve, but thanks for the Guzzle link, because you gave me a big hint! 🥳

I changed from xdebug.mode=develop,coverage to xdebug.mode=debug,coverage and now everything works as expected.

Thank you very much.

@mszabo-wikia
Copy link

mszabo-wikia commented May 13, 2024

@eleftrik you're very likely running into XDebug feature 2222. XDebug 3.3.0 and newer made it so that all locals alongside the stack of the last eight thrown exceptions are kept alive in memory until the process or request finishes if xdebug.mode=develop, breaking standard destructor semantics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants