PHP and PHPUnit: Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
If you’re getting the following error while running PHPUnit tests, check if the following is true:
- The unit test returning the segfault uses a test double function: createMock(), createStub(), etc.
- The mocked object has a
- In the
__destruct()function, the last method call is a public method, that returns the object (self/static return type).
If that is the case, try to make your last method call private or make it return
void. If that worked, let me know in a comment below, and if you can – explain why that happens 🙂 My guess is that the last method call is accessing a self reference to the object, after the object has been destroyed, hence the segfault error which means that an invalid memory space has been accessed.
Update: I have created a reproduction repository https://github.com/DragosMocrii/php-bug-destruct-segfault containing more complete information about the bug and how to temporarily get around it. PHP bug report created at https://github.com/php/php-src/issues/12373 .