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

Segmentation fault @ PHP 8.1 #4844

Closed
b1rdex opened this issue Dec 22, 2021 · 6 comments
Closed

Segmentation fault @ PHP 8.1 #4844

b1rdex opened this issue Dec 22, 2021 · 6 comments
Labels
type/bug Something is broken

Comments

@b1rdex
Copy link

b1rdex commented Dec 22, 2021

Q A
PHPUnit version 9.5.10
PHP version 8.1.1
Installation Method Composer

Summary

We have some code that worked without any issues on PHP 8.0, but it's failing with a segmentation fault on 8.1.
I'm not sure whether it's a PHPUnit or PHP issue... So please see the code. Mock creation triggers the problem.

Current behavior

Segmentation fault.

How to reproduce

Test repo: https://github.com/b1rdex/php-8.1-segfault

Expected behavior

No problem :)

@b1rdex b1rdex added the type/bug Something is broken label Dec 22, 2021
@sebastianbergmann
Copy link
Owner

sebastianbergmann commented Dec 22, 2021

You have found a problem in the PHP runtime that leads to a segmentation fault. An issue like this has to be reported here using a minimal, self-contained, reproducing test case.

Please note that a test case that needs to be run through PHPUnit does not qualify as either "minimal" or "self-contained" when reporting bugs for the PHP runtime. Best practices for reporting bugs in PHP are documented here.

@b1rdex
Copy link
Author

b1rdex commented Dec 22, 2021

I reported it here because I'm not sure that it's just a PHP issue. Mock creation is failing only in the data provider – creating it in a test works fine. Anyway, I've reported it to PHP – php/php-src#7809. Let's see how it goes.

@cmb69
Copy link

cmb69 commented Dec 22, 2021

While there are cases where userland code can trigger a segfault due to stack overflow, a null pointer dereference is always a bug in PHP. However, I have to admit that this mockery stretches what PHP has to handle. :)

@DragosMocrii
Copy link

DragosMocrii commented Oct 6, 2023

Ran into a similar issue and spent the evening trying to understand what happened (PHP 8.2, PHPUnit 10.3). Turns out it was because I was mocking a class that had a __destruct method, which was calling a public method as last statement: https://dragoshmocrii.com/php-and-phpunit-process-finished-with-exit-code-139-interrupted-by-signal-11-sigsegv/

I believe that the cause of the segfault is null pointer dereferencing, but can't put my finger on it.

@b1rdex
Copy link
Author

b1rdex commented Oct 6, 2023

@DragosMocrii please create a minimal reproduction and report to https://github.com/php/php-src/

@DragosMocrii
Copy link

@b1rdex just did! php/php-src#12373

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is broken
Projects
None yet
Development

No branches or pull requests

4 participants