protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

protobuf bool serilize bug

Open lwjtjm opened this issue 3 years ago • 5 comments

if proto message have a bool,but set is 222(not true,false 0,1), parse successfull,but the message remain filed is missing.

lwjtjm avatar Dec 03 '22 17:12 lwjtjm

debug version is fine,but release is not ok.

lwjtjm avatar Dec 03 '22 18:12 lwjtjm

Are you able to provide a more detailed example on how we can recreate this problem?

esorot avatar Dec 09 '22 16:12 esorot

the enviroment is windows mingw , I try windows msvc is ok.

// message as follows message HelloRequest { bool isW = 1; string name = 2; }

HelloRequest request;
struct test{
    bool a;
    int  b;
};

test bT;
*((unsigned char*)&bT.a)=138;      //when bool is random value and over 128, parse is fine,but the value after bool is not ok. 
request.set_isw(1);
request.set_name("hello");
std::string seriString = request.SerializeAsString();

HelloRequest request2;
if(!request2.ParseFromString(seriString)){
	 std::cout << "parse failed"<<std::endl;
}
std::cout << "request name:"<<request2.name();

result print as follows,"hello" is not pirnt request name:

lwjtjm avatar Dec 12 '22 05:12 lwjtjm

request.set_isw(1) should be request.set_isw(bT.a)

lwjtjm avatar Dec 12 '22 05:12 lwjtjm

The situation we encounter is that the bool value in the structure is uninitialized, and the random value is greater than 128

lwjtjm avatar Dec 12 '22 05:12 lwjtjm

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

github-actions[bot] avatar Dec 27 '23 10:12 github-actions[bot]

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.

This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.

github-actions[bot] avatar Jan 10 '24 10:01 github-actions[bot]