You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by "heartplus (via GitHub)" <gi...@apache.org> on 2023/08/03 02:41:52 UTC

[I] _arena of RedisReply should not be swapped as it always point to RedisResponse._arena (brpc)

heartplus opened a new issue, #2343:
URL: https://github.com/apache/brpc/issues/2343

   **Describe the bug (描述bug)**
   
   inline void RedisReply::Swap(RedisReply& other) {
             std::swap(_type, other._type);
             std::swap(_length, other._length);
             std::swap(_data.padding[0], other._data.padding[0]);
             std::swap(_data.padding[1], other._data.padding[1]);
             std::swap(_arena, other._arena);                                        <<<<<<<<<<---------  _arena should not be swapped
   }
   
   
   **To Reproduce (复现方法)**
   
   TEST_F(ClientInitTest, RedisResponse) {
       std::string msg = "+";
       msg.resize(300, 'x');
       msg.append("\r\n");
   
       brpc::RedisResponse* resp1 = new brpc::RedisResponse();
       brpc::RedisResponse* resp2 = new brpc::RedisResponse();
   
       resp1->Swap(resp2);
   
       char* ptr = (char*)resp2;
       delete resp2;
       // make sure memory is definitely freed
       memset(ptr, 0xff, sizeof(brpc::RedisResponse));
   
       butil::IOBuf buf;
       buf.append(msg);
       auto err = resp1->ConsumePartialIOBuf(buf, 1);
       ASSERT_EQ(0, err);
       delete resp1;
   }
   
   **Expected behavior (期望行为)**
   no segment fault
   
   **Versions (各种版本)**
   OS:  all
   Compiler:  all
   brpc: all
   protobuf: all
   
   **Additional context/screenshots (更多上下文/截图)**
   no 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


Re: [I] _arena of RedisReply should not be swapped as it always point to RedisResponse._arena (brpc)

Posted by "zyearn (via GitHub)" <gi...@apache.org>.
zyearn closed issue #2343: _arena of RedisReply should not be swapped as it always point to RedisResponse._arena 
URL: https://github.com/apache/brpc/issues/2343


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org