Hosting error under YII2 framework - "GPBDecodeException: Error occurred during parsing: Fail to push limit"

55 views
Skip to first unread message

Евгений Белоусов

unread,
Aug 18, 2021, 5:04:27 AMAug 18
to Protocol Buffers
Hi.
Version Protobuf: v3.17.3
Language: PHP.
The web portal is developed on the basis of the YII2 framework.
I have downloaded the PHP SDK for Cloud Speech-to-Text for converting recorded audio (mp3) speech to text.
This extension uses Protobuf to work with audio streams.

With this request, I send an audio file for transcription:

In my controller it looks like this:
"
$audioFile = $_SERVER['DOCUMENT_ROOT'] . '/frontend/web/audiofiles/380633470210_2021-05-13 115637.mp3';

                // change these variables if necessary
                $encoding = AudioEncoding::MP3;
                $sampleRateHertz = 44100;       
                       
                $languageCode = 'uk-UA';
// get contents of a file into a string
                $content = file_get_contents($audioFile);

                // set string as audio content
                $audio = (new RecognitionAudio())
                    ->setContent($content);

                // set config
                $config = (new RecognitionConfig())
                    ->setEncoding($encoding)
                    ->setSampleRateHertz($sampleRateHertz)
                    ->setLanguageCode($languageCode);   

                // create the speech client
                $client = new SpeechClient();
                
                // create the asyncronous recognize operation
                $operation = $client->longRunningRecognize($config, $audio);
                $operation->pollUntilComplete();
if ($operation->operationSucceeded()) {
                    $response = $operation->getResult();

                    $comment = '';

                    // each result is for a consecutive portion of the audio. iterate
                    // through them to get the transcripts for the entire audio file.
                    foreach ($response->getResults() as $result) {
                        $alternatives = $result->getAlternatives();
                        $mostLikely = $alternatives[0];
                        $transcript = $mostLikely->getTranscript();
                        $confidence = $mostLikely->getConfidence();

                        $comment .= '(' . $confidence . '): ' . $transcript  . PHP_EOL;
                    }
                }
$client->close();
"

On the local version of the site (Openserver, PHP 7.1.32, Apache API 20120211) everything works - I get lines of transcribed text in the $comment variable.

On hosting (PHP 7.3.15-3 + ubuntu16.04.1 + deb.sury.org, Apache/2.4.41) I get an error:

"Google\Protobuf\Internal\GPBDecodeException: Error occurred during parsing: Fail to push limit. in /var/www/4servicetp_ru/bat/vendor/google/protobuf/src/Google/Protobuf/Internal/CodedInputStream.php:367
Stack trace:
#0 /var/www/4servicetp_ru/bat/vendor/google/protobuf/src/Google/Protobuf/Internal/CodedInputStream.php(390): Google\Protobuf\Internal\CodedInputStream->pushLimit(917)
#1 /var/www/4servicetp_ru/bat/vendor/google/protobuf/src/Google/Protobuf/Internal/GPBWire.php(286): Google\Protobuf\Internal\CodedInputStream->incrementRecursionDepthAndPushLimit(917, 0, 0)
#2 /var/www/4servicetp_ru/bat/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(437): Google\Protobuf\Internal\GPBWire::readMessage(Object(Google\Protobuf\Internal\CodedInputStream), Object(Google\Protobuf\Internal\FileDescriptorProto))
#3 /var/www/4servicetp_ru/bat/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(527): Google\Protobuf\Internal\Message::parseFieldFromStreamNoTag(Object(Google\Protobuf\Internal\CodedInputStream), Object(Google\Protobuf\Internal\FieldDescriptor), Object(Google\Protobuf\Internal\FileDescriptorProto))
#4 /var/www/4servicetp_ru/bat/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(823): Google\Protobuf\Internal\Message->parseFieldFromStream(10, Object(Google\Protobuf\Internal\CodedInputStream), Object(Google\Protobuf\Internal\FieldDescriptor))
#5 /var/www/4servicetp_ru/bat/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(787): Google\Protobuf\Internal\Message->parseFromStream(Object(Google\Protobuf\Internal\CodedInputStream))
#6 /var/www/4servicetp_ru/bat/vendor/google/protobuf/src/Google/Protobuf/Internal/DescriptorPool.php(61): Google\Protobuf\Internal\Message->mergeFromString('\n\x95\x07\n,google/clo...')
#7 /var/www/4servicetp_ru/bat/vendor/google/cloud-speech/metadata/V1P1Beta1/Resource.php(42): Google\Protobuf\Internal\DescriptorPool->internalAddGeneratedFile('\n\x95\x07\n,google/clo...', true)
#8 /var/www/4servicetp_ru/bat/vendor/google/cloud-speech/metadata/V1P1Beta1/CloudSpeech.php(21): GPBMetadata\Google\Cloud\Speech\V1P1Beta1\Resource::initOnce()
#9 /var/www/4servicetp_ru/bat/vendor/google/cloud-speech/src/V1p1beta1/SpeechContext.php(79): GPBMetadata\Google\Cloud\Speech\V1P1Beta1\CloudSpeech::initOnce()
#10 /var/www/4servicetp_ru/bat/backend/controllers/AnketaController.php(748): Google\Cloud\Speech\V1p1beta1\SpeechContext->__construct()
#11 [internal function]: backend\controllers\AnketaController->actionTranscribe('9')
#12 /var/www/4servicetp_ru/bat/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#13 /var/www/4servicetp_ru/bat/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#14 /var/www/4servicetp_ru/bat/vendor/yiisoft/yii2/base/Module.php(534): yii\base\Controller->runAction('transcribe', Array)
#15 /var/www/4servicetp_ru/bat/vendor/yiisoft/yii2/web/Application.php(104): yii\base\Module->runAction('anketa/transcri...', Array)
#16 /var/www/4servicetp_ru/bat/vendor/yiisoft/yii2/base/Application.php(392): yii\web\Application->handleRequest(Object(yii\web\Request))
#17 /var/www/4servicetp_ru/bat/backend/web/index.php(17): yii\base\Application->run()"

"
public function pushLimit($byte_limit)
    {
        // Current position relative to the beginning of the stream.
        $current_position = $this->current();
        $old_limit = $this->current_limit;

        // security: byte_limit is possibly evil, so check for negative values
        // and overflow.
        if ($byte_limit >= 0 &&
            $byte_limit <= PHP_INT_MAX - $current_position &&
            $byte_limit <= $this->current_limit - $current_position) {
            $this->current_limit = $current_position + $byte_limit;
            $this->recomputeBufferLimits();

        } else {

            throw new GPBDecodeException("Fail to push limit.");
        }

        return $old_limit;
    }
"

I talked about this issue in a chat with a Google specialist and he directed me here, because in his opinion the problem is precisely in the work of Protobuf.
I would be grateful for opinions and tips on what could be the cause of this error.


Евгений Белоусов

unread,
Aug 18, 2021, 5:11:25 AMAug 18
to Protocol Buffers
Fixed line numbers as in the repository:

"Google\Protobuf\Internal\GPBDecodeException: Error occurred during parsing: Fail to push limit. in /var/www/4servicetp_ru/bat/vendor/google/protobuf/src/Google/Protobuf/Internal/CodedInputStream.php:340
Stack trace:
#0 /var/www/4servicetp_ru/bat/vendor/google/protobuf/src/Google/Protobuf/Internal/CodedInputStream.php(363): Google\Protobuf\Internal\CodedInputStream->pushLimit(917)..."

среда, 18 августа 2021 г. в 12:04:27 UTC+3, Евгений Белоусов:

Евгений Белоусов

unread,
Aug 19, 2021, 8:04:57 AMAug 19
to Protocol Buffers
Fail to push limit. can occur if you modify the auto generated protobuf metadata files. For example, if you upload files via an FTP client. Some versions of FileZilla modify line endings, see https://wiki.filezilla-project.org/Data_Type. Removal of any characters from the binary data results in unexpected byte length comparisons. Think of it like serialized data: s:5:"123" would fail because the string length is 3 when it was expected to be 5.
You can change the transfer data type in FileZilla via the main menu under Transfer -> Transfer type and selecting Binary. Then reupload all the vendor files.
среда, 18 августа 2021 г. в 12:11:25 UTC+3, Евгений Белоусов:
Reply all
Reply to author
Forward
0 new messages