Page MenuHomePhabricator

Invariant failed: Bad SourceRange length
Closed, ResolvedPublic

Description

https://logstash.wikimedia.org/app/kibana#/doc/logstash-*/logstash-2019.11.26/parsoid-php?id=AW6m6BR-arkxubcmhIAw&_g=h@44136fa

#0 /srv/deployment/parsoid/deploy-cache/revs/e7faa19d48c07f7322de767e8848f81470091658/src/src/Tokens/SourceRange.php(81): Wikimedia\Assert\Assert::invariant(boolean, string)
#1 /srv/deployment/parsoid/deploy-cache/revs/e7faa19d48c07f7322de767e8848f81470091658/src/src/Wt2Html/PP/Processors/WrapTemplates.php(1076): Parsoid\Tokens\SourceRange->substr(string)
#2 /srv/deployment/parsoid/deploy-cache/revs/e7faa19d48c07f7322de767e8848f81470091658/src/src/Wt2Html/PP/Processors/WrapTemplates.php(1247): Parsoid\Wt2Html\PP\Processors\WrapTemplates::encapsulateTemplates(DOMDocument, Parsoid\Wt2Html\PageConfigFrame, array, array)
#3 /srv/deployment/parsoid/deploy-cache/revs/e7faa19d48c07f7322de767e8848f81470091658/src/src/Wt2Html/PP/Processors/WrapTemplates.php(1260): Parsoid\Wt2Html\PP\Processors\WrapTemplates::wrapTemplatesInTree(DOMDocument, Parsoid\Wt2Html\PageConfigFrame, DOMElement)
#4 /srv/deployment/parsoid/deploy-cache/revs/e7faa19d48c07f7322de767e8848f81470091658/src/src/Wt2Html/DOMPostProcessor.php(151): Parsoid\Wt2Html\PP\Processors\WrapTemplates::run(DOMElement, Parsoid\Config\Env, array, boolean)
#5 /srv/deployment/parsoid/deploy-cache/revs/e7faa19d48c07f7322de767e8848f81470091658/src/src/Wt2Html/DOMPostProcessor.php(828): Parsoid\Wt2Html\DOMPostProcessor->Parsoid\Wt2Html\{closure}(DOMElement, Parsoid\Config\Env, array, boolean)
#6 /srv/deployment/parsoid/deploy-cache/revs/e7faa19d48c07f7322de767e8848f81470091658/src/src/Wt2Html/DOMPostProcessor.php(881): Parsoid\Wt2Html\DOMPostProcessor->doPostProcess(DOMDocument)
#7 /srv/deployment/parsoid/deploy-cache/revs/e7faa19d48c07f7322de767e8848f81470091658/src/src/Wt2Html/DOMPostProcessor.php(898): Parsoid\Wt2Html\DOMPostProcessor->process(DOMDocument)
#8 /srv/deployment/parsoid/deploy-cache/revs/e7faa19d48c07f7322de767e8848f81470091658/src/src/Wt2Html/ParserPipeline.php(148): Parsoid\Wt2Html\DOMPostProcessor->processChunkily(string, array)
#9 /srv/deployment/parsoid/deploy-cache/revs/e7faa19d48c07f7322de767e8848f81470091658/src/src/Wt2Html/ParserPipeline.php(198): Parsoid\Wt2Html\ParserPipeline->parseChunkily(string, array)
#10 /srv/deployment/parsoid/deploy-cache/revs/e7faa19d48c07f7322de767e8848f81470091658/src/src/Wt2Html/ParserPipelineFactory.php(299): Parsoid\Wt2Html\ParserPipeline->parseToplevelDoc(string, array)
#11 /srv/deployment/parsoid/deploy-cache/revs/e7faa19d48c07f7322de767e8848f81470091658/src/src/WikitextContentModelHandler.php(78): Parsoid\Wt2Html\ParserPipelineFactory->parse(string)
#12 /srv/deployment/parsoid/deploy-cache/revs/e7faa19d48c07f7322de767e8848f81470091658/src/src/Parsoid.php(89): Parsoid\WikitextContentModelHandler->toHTML(Parsoid\Config\Env)
#13 /srv/deployment/parsoid/deploy-cache/revs/e7faa19d48c07f7322de767e8848f81470091658/src/src/Parsoid.php(117): Parsoid\Parsoid->parseWikitext(MWParsoid\Config\PageConfig, array)
#14 /srv/deployment/parsoid/deploy-cache/revs/e7faa19d48c07f7322de767e8848f81470091658/src/extension/src/Rest/Handler/ParsoidHandler.php(576): Parsoid\Parsoid->wikitext2html(MWParsoid\Config\PageConfig, array, NULL)
#15 /srv/deployment/parsoid/deploy-cache/revs/e7faa19d48c07f7322de767e8848f81470091658/src/extension/src/Rest/Handler/PageHandler.php(52): MWParsoid\Rest\Handler\ParsoidHandler->wt2html(Parsoid\Config\Env, array)
#16 /srv/mediawiki/php-1.35.0-wmf.5/includes/Rest/Router.php(315): MWParsoid\Rest\Handler\PageHandler->execute()
#17 /srv/mediawiki/php-1.35.0-wmf.5/includes/Rest/Router.php(285): MediaWiki\Rest\Router->executeHandler(MWParsoid\Rest\Handler\PageHandler)
#18 /srv/mediawiki/php-1.35.0-wmf.5/includes/Rest/EntryPoint.php(116): MediaWiki\Rest\Router->execute(MediaWiki\Rest\RequestFromGlobals)
#19 /srv/mediawiki/php-1.35.0-wmf.5/includes/Rest/EntryPoint.php(83): MediaWiki\Rest\EntryPoint->execute()
#20 /srv/mediawiki/php-1.35.0-wmf.5/rest.php(31): MediaWiki\Rest\EntryPoint::main()
#21 /srv/mediawiki/w/rest.php(3): require(string)
#22 {main}

Similar message to T236868 but different source.

Event Timeline

Arlolra triaged this task as Medium priority.Nov 26 2019, 5:27 PM
Arlolra moved this task from Backlog to Bugs, Notices, Crashers on the Parsoid-PHP board.

Reproducible!

$ tools/fetch-wt.js --domain fr.wikipedia.org 164858496 > T239252.wt
$ php bin/parse.php --pageName 'Utilisateur:Warp3/test4' --domain fr.wikipedia.org < T239252.wt
[warn/dsr/inconsistent] DSR inconsistency: cs/s mismatch for node: span s:4830 ; cs:4829
[warn/dsr/inconsistent] DSR inconsistency: cs/s mismatch for node: span s:3799 ; cs:3798
Wikimedia\Assert\InvariantException from line 217 of /home/cananian/Projects/Wikimedia/Parsoid/vendor/wikimedia/assert/src/Assert.php: Invariant failed: Bad SourceRange length

Minimal repro case:

<includeonly>{| border='1'
|}
</includeonly><noinclude>
{{Documentation|contenu=
== Exemple ==

}}<!-- fin contenu -->
<noinclude>


<!----
</noinclude>
</noinclude>
--->

With command-line:

php bin/parse.php --pageName 'Utilisateur:Warp3/test4' --domain fr.wikipedia.org --trace dsr < T239252n.wt

Not apparently UTF-8 related; what's happening is that WrapTemplates is getting confused and trying to set the end of the wrapping region before the start of it.

The <templatestyles> extension appears to be implicated as well.

Alternate reproduction:

php bin/parse.php --pageName 'User:cscott/T239252' --domain en.wikipedia.org --trace tsp,html,dsr,tplwrap < /dev/null

Change 556028 had a related patch set uploaded (by Sbailey; owner: Sbailey):
[mediawiki/services/parsoid@master] Fix for invariant failed: Bad SourceRange length

https://gerrit.wikimedia.org/r/556028

Change 556028 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Fix for invariant failed: Bad SourceRange length

https://gerrit.wikimedia.org/r/556028

This now results in the more typical,

[error] Do not have necessary info. to encapsulate Tpl: 2 Start Elt : <meta typeof="mw:Transclusion" about="#mwt682" data-object-id="6051"/> End Elt   : <meta typeof="mw:Transclusion/End" about="#mwt682" data-object-id="6491"/> Start DSR : [2441,1980,0,0] End   DSR : [null,1980,null,null]

Similar to other encapsulation tasks like T208793 and T115394