Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protobuf php extension automatically modifies the first value, when a message has exactly 32 fields, we modify the last value. #9440

Closed
simon-hi opened this issue Jan 26, 2022 · 0 comments · Fixed by protocolbuffers/upb#497
Assignees
Labels

Comments

@simon-hi
Copy link

simon-hi commented Jan 26, 2022

What version of protobuf and what language are you using?
Version: 3.19.1
Language: PHP

What operating system (Linux, Windows, ...) and version?
Linux(CentOS 8,4.18.0-305.19.1.el8_4.x86_64)

What runtime / compiler are you using (e.g., python version or gcc version)
PHP 7.4.27 (cli) (built: Dec 14 2021 17:17:06) ( NTS )

pre-built binary from remi-release repo.

dnf install -y remi-release
dnf install php74 php74-cli

What did you do?
Steps to reproduce the behavior:

  1. use this protobuf definition.
syntax = "proto3";

package foo;

message HelloRequest {
  optional uint32 id = 1;
  optional uint32 random_name_a0 = 2;
  optional uint32 random_name_a1 = 3;
  optional uint32 random_name_a2 = 4;
  optional uint32 random_name_a3 = 5;
  optional uint32 random_name_a4 = 6;
  optional uint32 random_name_a5 = 7;
  optional uint32 random_name_a6 = 8;
  optional uint32 random_name_a7 = 9;
  optional uint32 random_name_a8 = 10;
  optional uint32 random_name_a9 = 11;
  optional uint32 random_name_b0 = 12;
  optional uint32 random_name_b1 = 13;
  optional uint32 random_name_b2 = 14;
  optional uint32 random_name_b3 = 15;
  optional uint32 random_name_b4 = 16;
  optional uint32 random_name_b5 = 17;
  optional uint32 random_name_b6 = 18;
  optional uint32 random_name_b7 = 19;
  optional uint32 random_name_b8 = 20;
  optional uint32 random_name_b9 = 21;
  optional uint32 random_name_c0 = 22;
  optional uint32 random_name_c1 = 23;
  optional uint32 random_name_c2 = 24;
  optional uint32 random_name_c3 = 25;
  optional uint32 random_name_c4 = 26;
  optional uint32 random_name_c5 = 27;
  optional uint32 random_name_c6 = 28;
  optional uint32 random_name_c7 = 29;
  optional uint32 random_name_c8 = 30;
  optional uint32 random_name_c9 = 31;
  optional string version = 32;
}

the keys are:

  • exactly 32 fields in one message.
  • the type of least field is uint32.
  • optional modifier.
  1. reproduce
protoc --version
# libprotoc 3.19.1

protoc --php_out=php demo.proto
require "php/Foo/HelloRequest.php";
$req = new \Foo\HelloRequest;
$req->setId(8);  // must be even
$req->getId();  // as expected, returns 8
$req->setVersion('1');  // no matter the value set for 'version'
$req->getId();  // wrong, returns 9

What did you expect to see

get as i set

What did you see instead?

get as i set ... +1

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment

  • Regarding php-ext, I have tried installing the pre-built version with dnf install, and installing the 3.19.3 version directly from source.
  • tried composer package 'google/protobuf' instead of php-ext 'protobuf', bug gone.
  • change least field type from uint32 to uint64 / string, bug gone.
  • add/remove one field in this message, bug gone.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants