Bug #81601 [Csd->Nab]: float - (int) float is sometimes bigger than 1
| From: | requinix@php.net | Date: | Fri, 10 Dec 2021 18:03:50 +0000 |
| Subject: | Bug #81601 [Csd->Nab]: float - (int) float is sometimes bigger than 1 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-238329@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81601&edit=1
ID: 81601
Updated by: requinix@php.net
Reported by: dktapps at pmmp dot io
Summary: float - (int) float is sometimes bigger than 1
-Status: Closed
+Status: Not a bug
Type: Bug
Package: Math related
Operating System: Linux
PHP Version: 8.0.13
Block user comment: N
Private report: N
New Comment:
> HOWEVER, the fact that debug backtraces contain the current values of parameter
> variables, rather than the values actually passed, is a very unexpected and
> confusing behaviour which really ought to be fixed.
See:
https://www.php.net/manual/en/migration70.incompatible.php#migration70.incompatible.other.func-parameter-modified
https://bugs.php.net/bug.php?id=79827
Previous Comments:
------------------------------------------------------------------------
[2021-12-10 17:20:43] dktapps at pmmp dot io
Hi all, the mystery has been solved.
The cause of the confusion was this code: https://github.com/pmmp/PocketMine-MP/blob/eb9012401b6510fc24df44d9ff5545c8094f7471/src/entity/ExperienceManager.php#L201
The variable
$progress is the name of a parameter, but its value is being overridden by
some value from PlayerExperienceChangeEvent, which does not check bounds. TL;DR: This was caused by
some third party code.
HOWEVER, the fact that debug backtraces contain the current values of parameter variables, rather
than the values actually passed, is a very unexpected and confusing behaviour which really ought to
be fixed.
------------------------------------------------------------------------
[2021-12-03 13:01:21] dktapps at pmmp dot io
I'll also mention that NO references are used in the stack, so I don't know how this is
happening.
------------------------------------------------------------------------
[2021-12-03 12:58:47] dktapps at pmmp dot io
Hi all, this issue recently occurred again despite additional checks in the code specifically
designed to trap this edge case. It looks like the value must be getting corrupted somewhere.
Unsuccessful trap: https://github.com/pmmp/PocketMine-MP/blob/6b7d0307afb36a7faca2dd65734e15000baf17ba/src/pocketmine/entity/Human.php#L401
Error thrown here: https://github.com/pmmp/PocketMine-MP/blob/6b7d0307afb36a7faca2dd65734e15000baf17ba/src/pocketmine/entity/Attribute.php#L196
https://crash.pmmp.io/view/5558770
------------------------------------------------------------------------
[2021-11-10 13:28:24] antonino dot spampinato86 at gmail dot com
Yes, the integer part of the float storage of the implicit integer cast is equivalent to the integer
part of the float. But from the source you mentioned I see two numbers with different lengths and I
suspect there is a problem with the scientific notation for 0. If you can also print with
var_dump(sprintf('%00.53F', $float)); when in source it checks if > 0 so you will have
two representations of the number that you can compare for debugging.
------------------------------------------------------------------------
[2021-11-10 09:39:26] php at leinertco dot com
Try to pass $newLevel as 3rd argument in setXpAndProgress, so you have its value in your logs. Maybe
this will help :/
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=81601
--
Edit this bug report at https://bugs.php.net/bug.php?id=81601&edit=1