Page MenuHomePhabricator

PHP 8: Fatal error while running Parsoid tests with opcache enabled
Closed, ResolvedPublic

Description

Trying to run Parsoid parser tests on PHP 8 with -d opcache.enable_cli=1 produces a strange fatal:

/usr/local/opt/php@8.0/bin/php -dopcache.enable_cli=1 bin/parserTests.php --wt2html --wt2wt --html2wt --html2html --selser true --quiet --knownFailures true tests/parser/sectionWrappingParserTests.txt
Loaded known failures from /Users/mateszabo/Wikia/parsoid-php/tests/parser/sectionWrappingParserTests-knownFailures.json
PHP Fatal error:  Uncaught TypeError: Wikimedia\Parsoid\Utils\Utils::isValidDSR(): Argument #1 ($dsr) must be of type ?Wikimedia\Parsoid\Core\DomSourceRange, Wikimedia\Parsoid\Core\DomSourceRange given, called in /Users/mateszabo/Wikia/parsoid-php/src/Wt2Html/PP/Handlers/CleanUp.php on line 227 and defined in /Users/mateszabo/Wikia/parsoid-php/src/Utils/Utils.php:202
Stack trace:
#0 /Users/mateszabo/Wikia/parsoid-php/src/Wt2Html/PP/Handlers/CleanUp.php(227): Wikimedia\Parsoid\Utils\Utils::isValidDSR(Object(Wikimedia\Parsoid\Core\DomSourceRange))
#1 /Users/mateszabo/Wikia/parsoid-php/src/Wt2Html/DOMPostProcessor.php(515): Wikimedia\Parsoid\Wt2Html\PP\Handlers\CleanUp::cleanupAndSaveDataParsoid(Array, Object(DOMElement), Object(Wikimedia\Parsoid\Config\Env), true, Object(stdClass))
#2 [internal function]: Wikimedia\Parsoid\Wt2Html\DOMPostProcessor->Wikimedia\Parsoid\Wt2Html\{closure}(Object(DOMElement), Object(Wikimedia\Parsoid\Config\Env), Array, true, Object(stdClass))
#3 /Users/mateszabo/Wikia/parsoid-php/src/Utils/DOMTraverser.php(80): call_user_func(Object(Closure), Object(DOMElement), Object(Wikimedia\Parsoid\Config\Env), Array, true, Object(stdClass))
#4 /Users/mateszabo/Wikia/parsoid-php/src/Utils/DOMTraverser.php(152): Wikimedia\Parsoid\Utils\DOMTraverser->callHandlers(Object(DOMElement), Object(Wikimedia\Parsoid\Config\Env), Array, true, Object(stdClass))
#5 /Users/mateszabo/Wikia/parsoid-php/src/Utils/DOMTraverser.php(166): Wikimedia\Parsoid\Utils\DOMTraverser->traverse(Object(Wikimedia\Parsoid\Config\Env), Object(DOMElement), Array, true, Object(stdClass))
#6 /Users/mateszabo/Wikia/parsoid-php/src/Utils/DOMTraverser.php(166): Wikimedia\Parsoid\Utils\DOMTraverser->traverse(Object(Wikimedia\Parsoid\Config\Env), Object(DOMElement), Array, true, NULL)
#7 /Users/mateszabo/Wikia/parsoid-php/src/Utils/DOMTraverser.php(166): Wikimedia\Parsoid\Utils\DOMTraverser->traverse(Object(Wikimedia\Parsoid\Config\Env), Object(DOMElement), Array, true, NULL)
#8 /Users/mateszabo/Wikia/parsoid-php/src/Wt2Html/DOMPostProcessor.php(150): Wikimedia\Parsoid\Utils\DOMTraverser->traverse(Object(Wikimedia\Parsoid\Config\Env), Object(DOMElement), Array, true, NULL)
#9 /Users/mateszabo/Wikia/parsoid-php/src/Wt2Html/DOMPostProcessor.php(859): Wikimedia\Parsoid\Wt2Html\DOMPostProcessor->Wikimedia\Parsoid\Wt2Html\{closure}(Object(DOMElement), Array, true)
#10 /Users/mateszabo/Wikia/parsoid-php/src/Wt2Html/DOMPostProcessor.php(909): Wikimedia\Parsoid\Wt2Html\DOMPostProcessor->doPostProcess(Object(DOMElement))
#11 /Users/mateszabo/Wikia/parsoid-php/src/Wt2Html/DOMPostProcessor.php(926): Wikimedia\Parsoid\Wt2Html\DOMPostProcessor->process(Object(DOMElement))
#12 /Users/mateszabo/Wikia/parsoid-php/src/Wt2Html/ParserPipeline.php(174): Wikimedia\Parsoid\Wt2Html\DOMPostProcessor->processChunkily('=1=\na\n\n{{1x|1=\n...', Array)
#13 /Users/mateszabo/Wikia/parsoid-php/src/Wt2Html/ParserPipeline.php(235): Wikimedia\Parsoid\Wt2Html\ParserPipeline->parseChunkily('=1=\na\n\n{{1x|1=\n...', Array)
#14 /Users/mateszabo/Wikia/parsoid-php/src/Wt2Html/ParserPipelineFactory.php(299): Wikimedia\Parsoid\Wt2Html\ParserPipeline->parseToplevelDoc('=1=\na\n\n{{1x|1=\n...', Array)
#15 /Users/mateszabo/Wikia/parsoid-php/src/Core/WikitextContentModelHandler.php(106): Wikimedia\Parsoid\Wt2Html\ParserPipelineFactory->parse('=1=\na\n\n{{1x|1=\n...')
#16 /Users/mateszabo/Wikia/parsoid-php/src/ParserTests/TestRunner.php(808): Wikimedia\Parsoid\Core\WikitextContentModelHandler->toDOM(Object(Wikimedia\Parsoid\Config\Env))
#17 /Users/mateszabo/Wikia/parsoid-php/src/ParserTests/TestRunner.php(889): Wikimedia\Parsoid\ParserTests\TestRunner->convertWt2Html(Object(Wikimedia\Parsoid\Config\Env), Object(Wikimedia\Parsoid\ParserTests\Test), 'wt2html', '=1=\na\n\n{{1x|1=\n...')
#18 /Users/mateszabo/Wikia/parsoid-php/src/ParserTests/TestRunner.php(1205): Wikimedia\Parsoid\ParserTests\TestRunner->runTest(Object(Wikimedia\Parsoid\ParserTests\Test), 'wt2html', Array)
#19 /Users/mateszabo/Wikia/parsoid-php/src/ParserTests/TestRunner.php(1426): Wikimedia\Parsoid\ParserTests\TestRunner->buildTasks(Object(Wikimedia\Parsoid\ParserTests\Test), Array, Array)
#20 /Users/mateszabo/Wikia/parsoid-php/src/ParserTests/TestRunner.php(1509): Wikimedia\Parsoid\ParserTests\TestRunner->processTest(Object(Wikimedia\Parsoid\ParserTests\Test), Array)
#21 /Users/mateszabo/Wikia/parsoid-php/bin/parserTests.php(65): Wikimedia\Parsoid\ParserTests\TestRunner->run(Array)
#22 /Users/mateszabo/Wikia/parsoid-php/tools/doMaintenance.php(53): ParserTests->execute()
#23 /Users/mateszabo/Wikia/parsoid-php/bin/parserTests.php(902): require_once('/Users/mateszab...')
#24 {main}
  thrown in /Users/mateszabo/Wikia/parsoid-php/src/Utils/Utils.php on line 202

This seems like some kind of PHP/opcache bug, as the types listed by the error seem to match (also confirmed by debugging), and the error does not occur when opcache is disabled.

Event Timeline

So, I reran the parsoid parser tests with a PHP 8.0.0 release build and a PHP 8.0.1 one, and I got no fatals with and without opcache. Would be nice if someone else could confirm, but it does look like whatever caused this error was fixed before the PHP 8 release.

 ~/D/c/mediawiki-services-parsoid $ php -v
Thu 14 Jan 20:31:17 2021
PHP 8.0.1 (cli) (built: Jan  8 2021 12:43:54) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.1, Copyright (c) Zend Technologies
    with Xdebug v3.0.2, Copyright (c) 2002-2021, by Derick Rethans
    with Zend OPcache v8.0.1, Copyright (c), by Zend Technologies

 ~/D/c/mediawiki-services-parsoid $ php -dopcache.enable_cli=1 bin/parserTests.php --wt2html --wt2wt --html2wt --html2html --selser true --quiet --knownFailures true tests/parser/sectionWrappingParserTests.txt

Loaded known failures from /Users/jdforrester/Documents/code/mediawiki-services-parsoid/tests/parser/sectionWrappingParserTests-knownFailures.json
==========================================================
SUMMARY:sectionWrappingParserTests.txt
Execution time: 9881.398ms
wt2html: 18 passed (0 unexpected) / 1 failed (0 unexpected)
wt2wt: 17 passed (0 unexpected) / 2 failed (0 unexpected)
html2html: 15 passed (0 unexpected) / 1 failed (0 unexpected)
html2wt: 15 passed (0 unexpected) / 1 failed (0 unexpected)
selser: 352 passed (0 unexpected) / 27 failed (0 unexpected)
TOTAL: 417 passed (0 unexpected) / 32 failed (0 unexpected)
No errors logged.
==========================================================
SUMMARY:ALL TESTS
TOTAL: 417 passed (0 unexpected) / 32 failed (0 unexpected)
417 total passed tests (expected 417), 32 total failures (expected 32)
0 errors logged.
--> NO UNEXPECTED RESULTS <--


 ~/D/c/mediawiki-services-parsoid $ php -dopcache.enable_cli=0 bin/parserTests.php --wt2html --wt2wt --html2wt --html2html --selser true --quiet --knownFailures true tests/parser/sectionWrappingParserTests.txt

Loaded known failures from /Users/jdforrester/Documents/code/mediawiki-services-parsoid/tests/parser/sectionWrappingParserTests-knownFailures.json
==========================================================
SUMMARY:sectionWrappingParserTests.txt
Execution time: 9866.76ms
wt2html: 18 passed (0 unexpected) / 1 failed (0 unexpected)
wt2wt: 17 passed (0 unexpected) / 2 failed (0 unexpected)
html2html: 15 passed (0 unexpected) / 1 failed (0 unexpected)
html2wt: 15 passed (0 unexpected) / 1 failed (0 unexpected)
selser: 352 passed (0 unexpected) / 27 failed (0 unexpected)
TOTAL: 417 passed (0 unexpected) / 32 failed (0 unexpected)
No errors logged.
==========================================================
SUMMARY:ALL TESTS
TOTAL: 417 passed (0 unexpected) / 32 failed (0 unexpected)
417 total passed tests (expected 417), 32 total failures (expected 32)
0 errors logged.
--> NO UNEXPECTED RESULTS <--

Yup, looks fixed to me.