Page MenuHomePhabricator

AbuseFilterCachingParser: PHP Warning: mb_strpos(): Offset not contained in string
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   PHP Warning: mb_strpos(): Offset not contained in string
exception.trace
from /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/Parser/AbuseFilterCachingParser.php(1272)
#0 [internal function]: MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/Parser/AbuseFilterCachingParser.php(1272): mb_strpos(string, string, integer)
#2 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/Parser/AbuseFilterCachingParser.php(721): MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterCachingParser->funcStrPos(array)
#3 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/Parser/AbuseFilterCachingParser.php(480): MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterCachingParser->callFunc(string, array)
#4 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/Parser/AbuseFilterCachingParser.php(1458): MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterCachingParser->evalNode(MediaWiki\Extension\AbuseFilter\Parser\AFPTreeNode)
#5 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/Parser/AbuseFilterCachingParser.php(590): MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterCachingParser->maybeDiscardNode(MediaWiki\Extension\AbuseFilter\Parser\AFPTreeNode)
#6 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/Parser/AbuseFilterCachingParser.php(599): MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterCachingParser->evalNode(MediaWiki\Extension\AbuseFilter\Parser\AFPTreeNode)
#7 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/Parser/AbuseFilterCachingParser.php(670): MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterCachingParser->evalNode(MediaWiki\Extension\AbuseFilter\Parser\AFPTreeNode)
#8 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/Parser/AbuseFilterCachingParser.php(577): MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterCachingParser->evalNode(MediaWiki\Extension\AbuseFilter\Parser\AFPTreeNode)
#9 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/Parser/AbuseFilterCachingParser.php(568): MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterCachingParser->evalNode(MediaWiki\Extension\AbuseFilter\Parser\AFPTreeNode)
#10 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/Parser/AbuseFilterCachingParser.php(568): MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterCachingParser->evalNode(MediaWiki\Extension\AbuseFilter\Parser\AFPTreeNode)
#11 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/Parser/AbuseFilterCachingParser.php(568): MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterCachingParser->evalNode(MediaWiki\Extension\AbuseFilter\Parser\AFPTreeNode)
#12 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/Parser/AbuseFilterCachingParser.php(568): MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterCachingParser->evalNode(MediaWiki\Extension\AbuseFilter\Parser\AFPTreeNode)
#13 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/Parser/AbuseFilterCachingParser.php(1458): MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterCachingParser->evalNode(MediaWiki\Extension\AbuseFilter\Parser\AFPTreeNode)
#14 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/Parser/AbuseFilterCachingParser.php(573): MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterCachingParser->maybeDiscardNode(MediaWiki\Extension\AbuseFilter\Parser\AFPTreeNode)
#15 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/Parser/AbuseFilterCachingParser.php(411): MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterCachingParser->evalNode(MediaWiki\Extension\AbuseFilter\Parser\AFPTreeNode)
#16 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/Parser/AbuseFilterCachingParser.php(337): MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterCachingParser->evalTree(MediaWiki\Extension\AbuseFilter\Parser\AFPSyntaxTree)
#17 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/Parser/AbuseFilterCachingParser.php(278): MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterCachingParser->intEval(string)
#18 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/Parser/AbuseFilterCachingParser.php(295): MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterCachingParser->checkSyntaxThrow(string)
#19 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/View/AbuseFilterViewTestBatch.php(220): MediaWiki\Extension\AbuseFilter\Parser\AbuseFilterCachingParser->checkSyntax(string)
#20 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/View/AbuseFilterViewTestBatch.php(208): MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewTestBatch->doTest()
#21 /srv/mediawiki/php-1.37.0-wmf.12/extensions/AbuseFilter/includes/Special/SpecialAbuseFilter.php(167): MediaWiki\Extension\AbuseFilter\View\AbuseFilterViewTestBatch->show()
#22 /srv/mediawiki/php-1.37.0-wmf.12/includes/specialpage/SpecialPage.php(646): MediaWiki\Extension\AbuseFilter\Special\SpecialAbuseFilter->execute(string)
#23 /srv/mediawiki/php-1.37.0-wmf.12/includes/specialpage/SpecialPageFactory.php(1362): SpecialPage->run(string)
#24 /srv/mediawiki/php-1.37.0-wmf.12/includes/MediaWiki.php(314): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, RequestContext)
#25 /srv/mediawiki/php-1.37.0-wmf.12/includes/MediaWiki.php(917): MediaWiki->performRequest()
#26 /srv/mediawiki/php-1.37.0-wmf.12/includes/MediaWiki.php(551): MediaWiki->main()
#27 /srv/mediawiki/php-1.37.0-wmf.12/index.php(53): MediaWiki->run()
#28 /srv/mediawiki/php-1.37.0-wmf.12/index.php(46): wfIndexMain()
#29 /srv/mediawiki/w/index.php(3): require(string)
#30 {main}
Impact

Unclear.

Notes

6 of these since deploy of 1.37.0-wmf.12 (T281153) to all wikis at 19:45 UTC.

cc: @DannyS712 since I notice a recent commit there.

Details

Event Timeline

Change 702915 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/AbuseFilter@master] Avoid passing invalid offset to mb_strpos

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

Hi @Daimona. Can you prepare a cherry pick of the fix for wmf/1.37.0-wmf.12?

Change 703902 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/AbuseFilter@wmf/1.37.0-wmf.13] Avoid passing invalid offset to mb_strpos

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

Hi @Daimona. Can you prepare a cherry pick of the fix for wmf/1.37.0-wmf.12?

Yup, done.

Hi @Daimona. Can you prepare a cherry pick of the fix for wmf/1.37.0-wmf.12?

Yup, done.

Your patch is for wmf.13, not wmf.12.

Change 703904 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/AbuseFilter@wmf/1.37.0-wmf.12] Avoid passing invalid offset to mb_strpos

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

Hi @Daimona. Can you prepare a cherry pick of the fix for wmf/1.37.0-wmf.12?

Yup, done.

Your patch is for wmf.13, not wmf.12.

Whoops, fixed. I've left the other one around in case it will be necessary later.

What's a good way to test this change?

What's a good way to test this change?

Going to Special:AbuseFilter/tools, writing strpos( "foo", "o", 123456 ) === -1 in the big text field, hitting "Evaluate", and making sure that no PHP warning is emitted (on logstash). This is also what caused the reported issue in the first place: somebody using that interface to test code. Unfortunately, it's impossible to get any feedback on-wiki because this is just a warning in PHP 7.2-7.4.

What's a good way to test this change?

Going to Special:AbuseFilter/tools, writing strpos( "foo", "o", 123456 ) === -1 in the big text field, hitting "Evaluate", and making sure that no PHP warning is emitted (on logstash). This is also what caused the reported issue in the first place: somebody using that interface to test code. Unfortunately, it's impossible to get any feedback on-wiki because this is just a warning in PHP 7.2-7.4.

Looks like my Wikipedia account doesn't have permission to do that so I'll send you a note when the change has been deployed to mwdebug servers and I'll ask you to test.

Change 703902 abandoned by DannyS712:

[mediawiki/extensions/AbuseFilter@wmf/1.37.0-wmf.13] Avoid passing invalid offset to mb_strpos

Reason:

1.37.0-wmf.13 was cancelled due to WMF holiday, see https://wikitech.wikimedia.org/wiki/Deployments/Yearly_calendar and T281154

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

(Just noting here for intra-task record that this could have been verified in Beta Cluster already if it weren't for Logstash being down there as of last quarter. Ref T233134.)

Note: this is still happening as of 1.37.0-wmf.17 at a rate of about 10/day -- concentrated on jawiki right now.

Change 702915 merged by jenkins-bot:

[mediawiki/extensions/AbuseFilter@master] Avoid passing invalid offset to mb_strpos

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

Change 703904 abandoned by Daimona Eaytoy:

[mediawiki/extensions/AbuseFilter@wmf/1.37.0-wmf.12] Avoid passing invalid offset to mb_strpos

Reason:

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

A couple of these were seen today. Still jawiki. Most recent request id: cc0ef11e-249b-4683-81da-f0649099bc64

A couple of these were seen today. Still jawiki. Most recent request id: cc0ef11e-249b-4683-81da-f0649099bc64

Jawiki is still on wmf.19, isn't it?

A couple of these were seen today. Still jawiki. Most recent request id: cc0ef11e-249b-4683-81da-f0649099bc64

Jawiki is still on wmf.19, isn't it?

Yes. Is the issue expected to be fixed in .20?

I believe so. Change 702915 merged last Wednesday and says "Included in: master, wmf/1.37.0-wmf.20" (and doesn't appear to have been backported).

Confirming that. We can leave this open until .20 is rolled out everywhere.