Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

HttpFoundation: race condition introduced by #46931 breaks Web Profiler Bar #47280

Copy link
Copy link
Closed
@DennisBirkholz

Description

@DennisBirkholz
Issue body actions

Symfony version(s) affected

5.4.11

Description

#46931 introduced a race condition between writing the profiler data and loading it as the browser now starts a XHR request to load the profiler data before the data is completely written.

The error produced when loading the incomplete profile dump is:

request.CRITICAL: Uncaught PHP Exception ErrorException: "Notice: unserialize(): Error at offset 3254883 of 3254908 bytes" at vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php line 126 {"exception":"[object] (ErrorException(code: 0): Notice: unserialize(): Error at offset 3254883 of 3254908 bytes at vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php:126)"

How to reproduce

Reproduction is difficult as it depends heavily on timing.
In general, the issue may occur for very large profile dumps stored on slow disks.

Possible Solution

This race condition can be fixed in two ways:

  1. Ensure the stored profile data on disk is always complete by storing the data into a temporary file and moving that file to the final location after everything is written in FileProfilerStorage.php#L177
  2. Use the @ operator on the unserialize operation in FileProfilerStorage.php#L124

I prefer solution 1 as solution 2 would hide other sources of corruption in the stored profile. A pull request for solution 1 will be provided shortly.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.