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

Test failure on 32-bit #51

Closed
remicollet opened this issue Oct 4, 2019 · 4 comments
Closed

Test failure on 32-bit #51

remicollet opened this issue Oct 4, 2019 · 4 comments

Comments

@remicollet
Copy link

remicollet commented Oct 4, 2019

There was 1 error:
1) ScssPhp\ScssPhp\Tests\SassSpecTest::testTests with data set #1137 ('1138/1980. libsass-closed-iss...ue_636', array('', '\nfoo {\n    $id: unique-id()...n}\n\n', array()), array('foo {\n  is-defined: true;\n ...;\n}\n', '', ''))
mt_rand() expects parameter 2 to be int, float given
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.5-1.fc32.noarch/usr/share/php/ScssPhp/ScssPhp/Compiler.php:6675
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.5-1.fc32.noarch/usr/share/php/ScssPhp/ScssPhp/Compiler.php:4606
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.5-1.fc32.noarch/usr/share/php/ScssPhp/ScssPhp/Compiler.php:2989
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.5-1.fc32.noarch/usr/share/php/ScssPhp/ScssPhp/Compiler.php:2960
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.5-1.fc32.noarch/usr/share/php/ScssPhp/ScssPhp/Compiler.php:2340
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.5-1.fc32.noarch/usr/share/php/ScssPhp/ScssPhp/Compiler.php:1808
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.5-1.fc32.noarch/usr/share/php/ScssPhp/ScssPhp/Compiler.php:1420
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.5-1.fc32.noarch/usr/share/php/ScssPhp/ScssPhp/Compiler.php:2312
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.5-1.fc32.noarch/usr/share/php/ScssPhp/ScssPhp/Compiler.php:1808
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.5-1.fc32.noarch/usr/share/php/ScssPhp/ScssPhp/Compiler.php:412
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.5-1.fc32.noarch/usr/share/php/ScssPhp/ScssPhp/Compiler.php:266
/builddir/build/BUILD/scssphp-98e10149058102817b493c5a147fa582cb62d46e/tests/SassSpecTest.php:139
--
There was 1 failure:
1) ScssPhp\ScssPhp\Tests\Base64VLQTest::testEncode with data set #5 ('+/////D', 2147483647)
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'+/////D'
+'e'
/builddir/build/BUILD/scssphp-98e10149058102817b493c5a147fa582cb62d46e/tests/Base64VLQTest.php:36
--

@remicollet remicollet changed the title Test failure on 32-b it Test failure on 32-bit Oct 4, 2019
@robocoder
Copy link
Member

@stof
Copy link
Member

stof commented Nov 5, 2019

I think the issue is in Base64VLQ::toVLQSigned.
When being passed 2^31-1 (the biggest signed 32-bit integer, which is what is expected to be supported by that input), it will return 2^32-2. This is bigger than PHP_INT_MAX, as it does not fit in a 32-bit signed integer (it would fit in a 32 bit unsigned integer).

On a 32 bit system, this code only supports integer up to 2^30 - 1 in a safe way.

The original Java implementation does not explicitly test for the output of such values (their test assert that decoding the encoded value bring back the same string, not that it has a specific value), so I'm not sure what is the expected encoding for 2^31-1. And maybe the Java implementation has a similar issue (and for sure, they don't care about bigger values as Java int is always a signed 32-bit integer. They do run some tests for values bigger than 2^30 - 1 though.

Anyway, do we expect to use such big number in the Base64VLQ encoding of sourcemaps ? If no, we could change the test to work with 2^30 - 1 instead.

@remicollet
Copy link
Author

Still have an issue on 32-bit

There was 1 error:

1) ScssPhp\ScssPhp\Tests\SassSpecTest::testTests with data set #1137 ('1138/1980. libsass-closed-iss...ue_636', array('', '\nfoo {\n    $id: unique-id()...n}\n\n', array()), array('foo {\n  is-defined: true;\n ...;\n}\n', '', ''))
mt_rand() expects parameter 2 to be integer, float given

/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.6-1.fc29.remi.i386/usr/share/php/ScssPhp/ScssPhp/Compiler.php:6940
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.6-1.fc29.remi.i386/usr/share/php/ScssPhp/ScssPhp/Compiler.php:4800
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.6-1.fc29.remi.i386/usr/share/php/ScssPhp/ScssPhp/Compiler.php:3148
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.6-1.fc29.remi.i386/usr/share/php/ScssPhp/ScssPhp/Compiler.php:3119
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.6-1.fc29.remi.i386/usr/share/php/ScssPhp/ScssPhp/Compiler.php:2443
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.6-1.fc29.remi.i386/usr/share/php/ScssPhp/ScssPhp/Compiler.php:1911
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.6-1.fc29.remi.i386/usr/share/php/ScssPhp/ScssPhp/Compiler.php:1519
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.6-1.fc29.remi.i386/usr/share/php/ScssPhp/ScssPhp/Compiler.php:2415
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.6-1.fc29.remi.i386/usr/share/php/ScssPhp/ScssPhp/Compiler.php:1911
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.6-1.fc29.remi.i386/usr/share/php/ScssPhp/ScssPhp/Compiler.php:412
/builddir/build/BUILDROOT/php-scssphp-scssphp-1.0.6-1.fc29.remi.i386/usr/share/php/ScssPhp/ScssPhp/Compiler.php:266
/builddir/build/BUILD/scssphp-5b3c9d704950d8f9637f5110c36c281ec47dc13c/tests/SassSpecTest.php:141

--

There was 1 failure:

1) ScssPhp\ScssPhp\Tests\Base64VLQTest::testEncode with data set #5 ('+/////D', 2147483647)
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'+/////D'
+'e'

/builddir/build/BUILD/scssphp-5b3c9d704950d8f9637f5110c36c281ec47dc13c/tests/Base64VLQTest.php:36

--

@robocoder
Copy link
Member

I'm closing this issue because the original issues are fixed.

That said, scssphp is not 32-bit compatible with all frameworks. Specifically, Zurb Foundation relies on some big number math, and I'm against the performance impact and scope of changes needed to further abstract the arithmetic operations in scssphp to support GMP and/or BCMath.

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

3 participants