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

A non-numeric value encountered in Stacktrace.php #816

Closed

Conversation

Deifinger
Copy link

I get string $index and observe "A non-numeric value encountered" error

7abf0c17e8

Please, take a look at my solution. I'm not sure that this is correct fix and the root of the problem

@ste93cry
Copy link
Collaborator

ste93cry commented May 8, 2019

It would be cool if you could share a little script reproducing the problem of if you can debug and tell us what's the value of the $index variable.

@ste93cry ste93cry added this to the 2.0 milestone May 8, 2019
@ste93cry ste93cry self-requested a review May 8, 2019 11:59
@Deifinger
Copy link
Author

@ste93cry That's my state before exception:

$argument = "???"
$index = "container"
$maxValueLength = 1024
$frame = Array
(
    [function] => "Illuminate\Container\{closure}"
    [type] => "->"
    [class] => "Illuminate\Foundation\Application"
    [file] => "/var/www/app/vendor/laravel/framework/src/Illuminate/Container/Container.php"
    [line] => 776
    [args] => Array
        (
            [container] => "???"
            [parameters] => "???"
        )

)

That happends when I make some Fatal error. See my example:

PHP Fatal error: Declaration of App\Utils\Sitemap\Generators\IndexGenerator::setAlias(string $alias) must be compatible with App\Utils\Sitemap\Contracts\Generator::setAlias(string $alias): App\Utils\Sitemap\Contracts\Generator in /var/www/app/app/Utils/Sitemap/Generators/IndexGenerator.php on line 9

@ste93cry
Copy link
Collaborator

ste93cry commented May 9, 2019

Are you using XDebug or some other debug extension? If so, can you try disabling it and retrying?

@Deifinger
Copy link
Author

@ste93cry Yeah, I have XDebug in my project. When I disabled it, the error disappeared.

@@ -311,7 +311,7 @@ protected function getFrameArgumentsValues(array $frame): array
$result = array_map([$this, 'serializeArgument'], $frame['args']);
} else {
foreach (array_values($frame['args']) as $index => $argument) {
$result['param' . ($index + 1)] = $this->serializeArgument($argument);
$result['param' . ((int)$index + 1)] = $this->serializeArgument($argument);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, the culprit of the problem as we found out is XDebug. The error occurs because it changes how the arguments of a stacktrace frame are reported by using the argument name as key of each value of the $args variable instead of its 0-based position in the function signature. Blindly casting $index to an integer then would result in some indesiderate results (e.g. foo would be converted to 0). The best fix we can do is to check whether the $index variable is a string or an integer and act accordingly. However, this exact same issue should have been fixed in #761 which is the reason why there is an if/else statement wrapping the loop, so I don't get why it happens and it would be cool if you could debug a bit more in depth to see what's happening

@sztyup
Copy link
Contributor

sztyup commented May 16, 2019

The screenshot you provided does not contain the fix by #763, could you make sure you are using the latest version of the library and see if the issue is still there?

@ste93cry
Copy link
Collaborator

The screenshot you provided does not contain the fix by #763

Good catch, I didn’t even noticed it!

@Deifinger
Copy link
Author

I'm going to update dependency on Monday and check the result

@Deifinger
Copy link
Author

@ste93cry Sorry for delay. I updated dependencies and now all works fine. I have the next versions:
sentry/sdk 2.0.2
sentry/sentry 2.0.1

Ticket going to be closed.

@Deifinger Deifinger closed this May 22, 2019
@Deifinger Deifinger deleted the bugfix/stacktrace-index branch May 22, 2019 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants