A friend of mine ran my project on his machine (Windows) and it runs without seg fault errors. On my machine (MacOS) the same code produces seg faults...
Segmentation fault on Eloquent query
Hi, I get a segmentation fault ("Segmentation fault: 11") when I run my Eloquent query. I don't know the cause and I'm wondering why I get this error?
This is my query that triggers the error:
$category_ids = [19,20,21];
$messages = Message::whereHas('categories', function($query) use ($category_ids) { $query->whereIn('categories.id', $category_ids); })->get();
The idea is that I want to get all messages that have at least 1 of the categories in the $category_ids array.
The Message model has a many-to-many relationship with the Category model. So the Message model contains:
public function categories() { return $this->belongsToMany('App\Category'); }
Whereas the Category model contains:
public function messages() { return $this->belongsToMany('App\Message'); }
There is a migration file for creating the pivot table.
What I find strange is that depending on the content of the $category_ids array the query succeeds or triggers a segmentation fault:
$category_ids = [19] // expected result, no seg-fault $category_ids = [19,20] // expected result, no seg-fault $category_ids = [19,20,21] // seg fault $category_ids = [19,20,21,22] // expected result, no seg-fault
I'm wondering what I could be doing wrong?
Please or to participate in this conversation.