-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
JIT Integer overflow ext/opcache/jit/ir/ir_fold.h #17430
Comments
This is caused by the folding of the index and zval size in the following codegen: php-src/ext/opcache/jit/zend_jit_ir.c Lines 12080 to 12081 in 11937b3
However, this can't cause real problems because we check earlier that the index is in bounds. Anyway, the undefined behaviour needs to be fixed in the IR repository. |
See php/php-src#17430 I changed the adds, subs, muls to use unsigned arithmetic because on 2-complement systems that's the same as signed arithmetic but without potential UB warnings. This essentially makes the wrapping behaviour defined. I only did this for 32 and 64 bit types because for 8 and 16 bit the operations will do integer promotion, avoiding the issue. There is also `val.i64 < 0 && val.i64 - 1 < 0` that I changed. This is because the second condition would be thrown away by the compiler because `val.i64 < 0` and signed wrapping is undefined.
See php/php-src#17430 I changed the adds, subs, muls to use unsigned arithmetic because on 2-complement systems that's the same as signed arithmetic but without potential UB warnings. This essentially makes the wrapping behaviour defined. I only did this for 32 and 64 bit types because for 8 and 16 bit the operations will do integer promotion, avoiding the issue. There is also `val.i64 < 0 && val.i64 - 1 < 0` that I changed. This is because the second condition would be thrown away by the compiler because `val.i64 < 0` and signed wrapping is undefined.
See php/php-src#17430 I changed the adds, subs, muls to use unsigned arithmetic because on 2-complement systems that's the same as signed arithmetic but without potential UB warnings. This essentially makes the wrapping behaviour defined. I only did this for 32 and 64 bit types because for 8 and 16 bit the operations will do integer promotion, avoiding the issue. There is also `val.i64 < 0 && val.i64 - 1 < 0` that I changed. This is because the second condition would be thrown away by the compiler because `val.i64 < 0` and signed wrapping is undefined.
This is now fixed in the IR repo and will soon make its way into PHP. |
Description
The following code:
Resulted in this output:
To reproduce:
PHP Version
nightly
Operating System
No response
The text was updated successfully, but these errors were encountered: