Skip to content

ErrorHandler: Exception with full stack trace is dumped in prod when it occurs before the kernel.request event #35448

@msarris

Description

@msarris

Symfony version(s) affected: 4.4, 5.0

Description
When an exception occurs before the kernel.request event (for example during Kernel::boot), then the exception is dumped with full stack trace, also in prod.

How to reproduce
Set APP_ENV=prod and throw an exception in Kernel::boot.

Possible Solution
Initialize Symfony\Component\ErrorHandler\ErrorHandler::$scopedErrors to 0 instead of 0x1FFF.

Or alter the construction of Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer not to rely on $this->scopedErrors being 0 to determine if the $debug parameter should be true.
Currently it's initialized as follows: new HtmlErrorRenderer(0 !== $this->scopedErrors)
(Symfony\Component\ErrorHandler\ErrorHandler line 700)

$scopedErrors is currently set to 0 (when kernel.debug is false) by calling the Symfony\Component\ErrorHandler\ErrorHandler::scopeAt method in Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure on line 96, which is trigged in the kernel.request event.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions