PHP Laravel Homestead - Segmentation fault (core dumped) when error should be thrown

Viewed 1576

I've googled a lot for this issue and came to one conclusion (of which I'm not 100% sure it's correct): the "Segmentation fault" error is something caused by PHP (not a package on your project or something?).

I removed a lot of my original question as I've found out something:

php artisan make:migration example

Content of the up() method:

dump('up()');
$thisShouldThrowAMethodNotExistError = User::whereSomething('nonExisting')->first();
dd('This is the end');

Then, normal way to execute the migration:

php artisan migrate
"up()"
Segmentation fault (core dumped)

Basically I found that whenever an error should be thrown by PHP (like in this case, the method whereSomething does not exist), the Segmentation fault is shown instead.

I have no idea where to look to fix this. Current versions:

  • Laravel/Homestead - 6.3.0
  • Vagrant - 2.1.5
  • VirtualBox - 5.2.18

Running the commands with php7.1 artisan migrate doesn't change anything for me.

Edit

After removing PHP 7.3.* and 7.2.* I still won't get an error like I usually got:

vagrant@homestead:~/Code/project$ php -v
PHP 7.1.20-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Jul 25 2018 10:07:09) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.20-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
    with blackfire v1.22.0~linux-x64-non_zts71, https://blackfire.io, by Blackfire
vagrant@homestead:~/Code/project$ php artisan migrate
 "up()"
Segmentation fault (core dumped)
2 Answers

Somehow it's fixed after a change on our development branch. The changes were just some files that had nothing to do with PHP, configuration, Laravel, just some minor code changes.

My theory at the moment is that some files were corrupt or something, which was resolved when I pulled the development branch again.

If anyone has a different theory, please let me know as I find this all very strange... :)

One of the option to cause such problem is Serialize.

I had the same problem when I was using Laravel Queue.

You can queue a lot of things, like a Mailable or a Job all it takes is to add implements ShouldQueue on your class.

Take a Mailable for example, usually you pass parameters to __construct and you save it in your class.

Like this:

public function __construct(Sale $sale)
{
    $this->sale         = $sale->withoutRelations();
...

BUT if you forget withoutRelations() function it will Serialize your object with links that will be lost after you UnSerialize your data back. That would cause the message

Segmentation fault (core dumped)

Simple test that show you that Queue is at fault if to disable it for testing. For that go to phpunit.xml file and change

<env name="QUEUE_DRIVER" value="sync"/>

to

<env name="QUEUE_DRIVER" value="null"/>

If your tests will pass now, it means that someone forgot withoutRelations() in some of your constructors that has implements ShouldQueue.

Related