You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Passing a null value to Model::getAttribute causes a segmentation fault, without any explanation, stack trace, error code, etc. I happened to be passing a field from my model, which happened to be a typo in a default scope's creating() function. With Model's __get(), I silently got null from "$model->sietField" (which was a typo):
$model->getAttribute($model->sietField);
I've tested this on PHP 5.5 and 7.0, on MacOS, Linux and Microsoft Azure. I'm guessing it's some sort of infinite recursion, but some sort of error handling would help. Perhaps not allowing null to be passed to getAttribute().
Azure happened to say this as an error message (whereas Linux/MacOS simply did a SIGSEGV):
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 24 bytes) in D:\home\site\wwwroot\laravel\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php on line 2710
It happens on both the CLI (tinker) and as a server module.
Steps To Reproduce:
Load any model instance and call something like:
use App\User;
$user = new User;
$user->getAttribute(null);
The text was updated successfully, but these errors were encountered:
Reproducible with Laravel 5.1.35 on PHP 7.0.10-2+dev.sury.org~trusty+1.
From /var/log/kern.log:
Oct 11 00:42:22 homestead kernel: [125335.114044] php-fpm7.0[8274]: segfault at 7fff3b26dff8 ip 00007fb1a0cddff5 sp 00007fff3b26e000 error 6 in php-fpm7.0[7fb1a0aa3000+38f000]
Looks like a endless recursive call.
getAttribute($key: null)
getAttributeValue($key: null)
hasGetMutator($key: null) and mutateAttribute($key: null, $value: null)
getAttribute($key: null)
A fix would be to have hasGetMutator check if $key is empty.
Description:
Passing a null value to Model::getAttribute causes a segmentation fault, without any explanation, stack trace, error code, etc. I happened to be passing a field from my model, which happened to be a typo in a default scope's creating() function. With Model's __get(), I silently got null from "$model->sietField" (which was a typo):
$model->getAttribute($model->sietField);
I've tested this on PHP 5.5 and 7.0, on MacOS, Linux and Microsoft Azure. I'm guessing it's some sort of infinite recursion, but some sort of error handling would help. Perhaps not allowing null to be passed to getAttribute().
Azure happened to say this as an error message (whereas Linux/MacOS simply did a SIGSEGV):
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 24 bytes) in D:\home\site\wwwroot\laravel\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php on line 2710
It happens on both the CLI (tinker) and as a server module.
Steps To Reproduce:
Load any model instance and call something like:
use App\User;
$user = new User;
$user->getAttribute(null);
The text was updated successfully, but these errors were encountered: