Page MenuHomePhabricator

Notice: Undefined index: 0 in /srv/mediawiki/php-1.28.0-wmf.9/extensions/Translate/tag/TranslatablePage.php on line XXX
Closed, DeclinedPublic

Description

Since deployment of 1.28.0-wmf.9 (T138555) the Translate extension is generating a concerning amount of notices which are overloading the log. Spotted by @elukey

Over an hour, there are 350 000 events for each six notices:

Notice message1 hour count
Notice: Undefined index: 0 in /srv/mediawiki/php-1.28.0-wmf.9/extensions/Translate/tag/TranslatablePage.php on line 299352073
Notice: Undefined index: 0 in /srv/mediawiki/php-1.28.0-wmf.9/extensions/Translate/tag/TranslatablePage.php on line 306352002
Notice: Undefined index: 0 in /srv/mediawiki/php-1.28.0-wmf.9/extensions/Translate/tag/TranslatablePage.php on line 300351915
Notice: Undefined index: 2 in /srv/mediawiki/php-1.28.0-wmf.9/extensions/Translate/tag/TranslatablePage.php on line 307351840
Notice: Undefined index: 0 in /srv/mediawiki/php-1.28.0-wmf.9/extensions/Translate/tag/TranslatablePage.php on line 307351749
Notice: Undefined index: 2 in /srv/mediawiki/php-1.28.0-wmf.9/extensions/Translate/tag/TranslatablePage.php on line 308351627

Can be seen at https://logstash.wikimedia.org/#/dashboard/elasticsearch/hhvm

Event Timeline

hashar created this task.Jul 6 2016, 9:28 AM
Restricted Application added subscribers: Luke081515, TerraCodes. · View Herald TranscriptJul 6 2016, 9:28 AM
Joe claimed this task.Jul 6 2016, 9:29 AM

This is all coming from 3 hosts, not a code issue, most likely.

Restarting hhvm does solve the issue (no more errors appear).

hashar added a comment.Jul 6 2016, 9:30 AM

That is only on a few hosts though:

mw1215 mw1256 and mw1236

hashar added a comment.Jul 6 2016, 9:32 AM

It started on mw1215 at 04:04:20 UTC.

hashar added a comment.Jul 6 2016, 9:58 AM

The code:

tag/TranslatablePage.php
while ( true ) { 
    $re = '~(<translate>)\s*(.*?)(</translate>)~s';
    $matches = array();
    $ok = preg_match_all( $re, $text, $matches, PREG_OFFSET_CAPTURE );

    if ( $ok === 0 ) { 
        break; // No matches
    }   

    // Do-placehold for the whole stuff
    $ph = TranslateUtils::getPlaceholder();
    $start = $matches[0][0][1];
    $len = strlen( $matches[0][0][0] );
    $end = $start + $len;
    $text = self::index_replace( $text, $ph, $start, $end );

It is in a while (true) loop that only breaks when the pattern matching finds no more matches (it returns (int)0).

But if the pattern matching fails for some reason, preg_match_all() returns boolean (false) which would not be caught and cause an infinite loop.

Given 1.27.0-wmf.9 is solely on group0 and given the amount of notices, I can only see that death loop as a good reason for the notices spam.

We should handle pattern error (preg_match_all returning false), maybe throw an exception.

Maybe consider having some hard limit as to the number of iteration the code can do and throw another out of limit exception.

Joe added a comment.Jul 6 2016, 10:18 AM

If what @hashar is suggesting happens, it might well be triggered by e.g. badly encoded strings within $text, and that might be due to a specific edit.

If that is the case, we will probably not see this happening much.

Removed as a blocker for wmf.9 since the code at TranslatablePage.php hasn't been touched since April. (see history for TranslatablePage.php )

Nikerabbit lowered the priority of this task from Unbreak Now! to Medium.Jul 7 2016, 11:48 AM
Nikerabbit added a subscriber: Nikerabbit.

Could just be a very long page as well. But it should fail in a better way. Reducing priority as the flood has stopped for now.

Joe removed Joe as the assignee of this task.Jul 8 2016, 7:43 AM
Joe added a subscriber: Joe.
Krinkle closed this task as Declined.Sep 13 2018, 12:12 AM
Krinkle added a subscriber: Krinkle.

Not seen in WMF Logstash for at least 30 days.

mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:11 PM