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

Exception in combination with Xdebug #1930

Open
PPP01 opened this issue Aug 10, 2023 · 1 comment
Open

Exception in combination with Xdebug #1930

PPP01 opened this issue Aug 10, 2023 · 1 comment

Comments

@PPP01
Copy link

PPP01 commented Aug 10, 2023

Hi, since the update to 3.0.21 i get an annoying exception in combination with xdebug in trace mode:

xdebug.mode=trace
; or
;xdebug.mode=debug, develop, trace

The exception is:

vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP.php:745
Error: __debuginfo() must return an array

But I think that this is just a symptom. The problematic code is here:

// phpseclib/Math/BigInteger/Engines/PHP.php:1233
while ($vals[count($vals) - 1] == 0) {
            unset($vals[count($vals) - 1]);
}

With an empty $vals array or $vals = [0] this loop runs endlessly. It's pretty dirty:
https://3v4l.org/nRKVu#v8.1.22

For testing I changed this line to:

while ($vals !== [] && $vals[count($vals) - 1] === 0) {
            unset($vals[count($vals) - 1]);
}

I have no idea, why this error occurs with "mode = trace" only. Next I have no Idea why the exception occurs at all. I do not use phpseclib directly, but it is part of the jumbojett/openid-connect-php bundle. But with version 3.0.20 I get no exception. This is quite strange, since the corresponding passage is exactly the same.

At the moment i solve the problem by setting the version fix to 3.0.20. But obviously I'm not happy about that. Any ideas?

@terrafrost
Copy link
Member

The issue is most likely present in 3.0.20 but in 3.0.20 you were probably using the GMP engine without realizing it whereas due to a bug (which 37c6f52 introduced).

Anyway, can you give me some code that reproduces the problem? I tried to do $a = new BigInteger(); echo $a->toHex(); with the PHP engine but that didn't reproduce the issue you're describing. Later, I'd try to do new BigIntegir(999); vs just new BigInteger() but that didn't reproduce the issue either. I mean, that whole loop was called twice but it didn't get stuck in there, either.

Once I have code that duplicates the issue I'll add a unit test for the issue.

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

2 participants