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 while loading media #3225

Closed
martynaskre opened this issue Mar 29, 2023 · 2 comments
Closed

Segmentation fault while loading media #3225

martynaskre opened this issue Mar 29, 2023 · 2 comments

Comments

@martynaskre
Copy link

After updating composer packages and installing version 10.7.14, media library causes SIGSEGV - core dumped error.

Copy from php8.1-error.log:

[29-Mar-2023 13:55:16] NOTICE: [pool valet] child 59740 started
[29-Mar-2023 13:55:16] WARNING: [pool valet] child 59607 exited on signal 11 (SIGSEGV - core dumped) after 98.153450 seconds from start

It is worth mentioning that this error only occurs in specific circumstances. We are using Livewire Powergrid package for building datatables. This code snippet below adds column to datatable and causes a segmentation fault:

->addColumn('preview',
    fn(Layout $model) => view('livewire.powergrid.image-column', [
        'src' => $model->getFirstMediaUrl(Layout::LAYOUT_COLLECTION),
        'alt' => $model->name,
        'isImage' => $model->getFirstMedia(Layout::LAYOUT_COLLECTION)->getTypeFromMime()
    ])
)

If we modify this function like shown below, then we dont get any errors and standard dd() output is displayed with correct media url.

->addColumn('preview',
    fn(Layout $model) => dd($model->getFirstMediaUrl(Layout::LAYOUT_COLLECTION)))
)

I think it might be related to #3219

@freekmurze
Copy link
Member

It's indeed related. It's fixed in the latest release.

More info here: #3224 (comment)

@cosmastech
Copy link
Contributor

cosmastech commented Mar 29, 2023

@martynaskre curious: how many media are being loaded?

I'm curious if the segfault is caused by having a massive number of media for a model or something else.

@freekmurze thoughts on adding a static property to the InteractsWithMedia trait like:

public static bool $setRelationForModels = false;

public function loadMedia(...)
{
    if (static::$setRelationForModels)
    {
        $collection->each->setRelation('model', $this);
    }
}

I know that laravel core does this frequently, and then will do something like:

public static function withoutSettingRelation(callable $fn) {
    $before = static::$setRelationForModels;
    static::$setRelationForModels = false;
    $fn();
    static::$setRelationForModels = $before;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants