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

Randomly failing string tests #71

Open
PurHur opened this issue May 5, 2019 · 4 comments
Open

Randomly failing string tests #71

PurHur opened this issue May 5, 2019 · 4 comments

Comments

@PurHur
Copy link

PurHur commented May 5, 2019

On my windows dev setup (standard git bash+docker) i get random crashes in the string tests... always the same but only in 10% of the runs.

https://gist.github.com/PurHur/4d4bb8548d4adfd5afa093fffc6c8a4b

Is that a problem at all? Or a cygwin/windows thing? I never saw that on debian machines.

@PurHur
Copy link
Author

PurHur commented May 5, 2019

Nothing was changed between the runs.

Compiling /compiler/lib/JIT.pre
Compiling /compiler/lib/JIT/Helper.pre
Compiling /compiler/lib/JIT/Builtin/Internal.pre
Compiling /compiler/lib/JIT/Builtin/MemoryManager.pre
Compiling /compiler/lib/JIT/Builtin/Output.pre
Compiling /compiler/lib/JIT/Builtin/Refcount.pre
Compiling /compiler/lib/JIT/Builtin/MemoryManager/Native.pre
Compiling /compiler/lib/JIT/Builtin/MemoryManager/PHP.pre
Compiling /compiler/lib/JIT/Builtin/Type/String_.pre
Compiling /compiler/lib/JIT/Builtin/Type/Value.pre
Compiling /compiler/lib/JIT/Call/Native.pre
Updating demo files
docker run -v /c/Users/purhur/php-compiler:/compiler ircmaxell/php-compiler:16.0
4-dev vendor/bin/phpunit
PHPUnit 8.2-g21ee615 by Sebastian Bergmann and contributors.

....................F.......................................      60 / 60 (100%)

Time: 1.07 minutes, Memory: 6.00 MB

There was 1 failure:

1) PHPCompiler\JITTest::testCases with data set #20 ('Basic String Operations',
'<?php\r\n$a = "hello";\r\n$b ...";\r\n', array('Basic String Operations\r\n', '
<?php\r\n$a = "hello";\r\n$b ...";\r\n', 'hello\r\nworld\r\nhello world\r\n'))
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'hello\n
-world\n
-hello world'
+''

/compiler/test/BaseTest.php:164
/compiler/test/BaseTest.php:145

FAILURES!
Tests: 60, Assertions: 88, Failures: 1.
make: *** [Makefile:70: test] Error 1

purhur@purhur-PC MINGW64 ~/php-compiler (test/str_repeat)
$ make test
docker run -v /c/Users/purhur/php-compiler:/compiler ircmaxell/php-compiler:16.0
4-dev php script/rebuild.php onlyChanged
Compiling /compiler/ext/types/strlen.pre
Compiling /compiler/lib/JIT.pre
Compiling /compiler/lib/JIT/Helper.pre
Compiling /compiler/lib/JIT/Builtin/Internal.pre
Compiling /compiler/lib/JIT/Builtin/MemoryManager.pre
Compiling /compiler/lib/JIT/Builtin/Output.pre
Compiling /compiler/lib/JIT/Builtin/Refcount.pre
Compiling /compiler/lib/JIT/Builtin/MemoryManager/Native.pre
Compiling /compiler/lib/JIT/Builtin/MemoryManager/PHP.pre
Compiling /compiler/lib/JIT/Builtin/Type/String_.pre
Compiling /compiler/lib/JIT/Builtin/Type/Value.pre
Compiling /compiler/lib/JIT/Call/Native.pre
Updating demo files
docker run -v /c/Users/purhur/php-compiler:/compiler ircmaxell/php-compiler:16.0
4-dev vendor/bin/phpunit
PHPUnit 8.2-g21ee615 by Sebastian Bergmann and contributors.

............................................................      60 / 60 (100%)

Time: 1.05 minutes, Memory: 6.00 MB

OK (60 tests, 88 assertions)

@ircmaxell
Copy link
Owner

There exists a memory corruption bug in the string code somewhere. What's happening is every once in a while a segfault is issued (though not often) and when it is the test fails with no output.

@PurHur
Copy link
Author

PurHur commented May 6, 2019

Thanks for explaining. I encountered this only on this machine... If a wonder comes by i fix it :P

@ircmaxell
Copy link
Owner

Code like this should be able to reliably segfault (or at least it does for me):

<?php

$test = 'a';

for ($i = 0; $i < 1000; $i++) {
    $test = $test . 'a';
}
echo $test;

echo "\n";

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