tesla1995 opened a new issue #955: BoundedQueue的pop_bottom()有内存越界的问题
URL: https://github.com/apache/incubator-brpc/issues/955
 
 
   **Describe the bug (描述bug)**
   brpc没有使用BoundedQueue的pop_bottom函数,但该函数实现存在内存越界的问题,如下图所示:
   
![pop_bottom](https://user-images.githubusercontent.com/11598872/68085314-a0dfd680-fe7a-11e9-898c-1dc7f93fceb5.png)
   
   
   **To Reproduce (复现方法)**
   测试代码为:
   #include <assert.h>
   #include <iostream>
   #include "butil/containers/bounded_queue.h"
   
   using namespace std;
   
   int main(void)
   {
     char storage[4 * sizeof(int)];
   
     butil::BoundedQueue<int> q(storage, sizeof(storage), 
butil::NOT_OWN_STORAGE);
     // 1, 2, 3, 4
     assert(q.push(1) == true);
     assert(q.push(2) == true);
     assert(q.push(3) == true);
     assert(q.push(4) == true);
   
     // x, x, x, 4
     assert(q.pop() == true);
     assert(q.pop() == true);
     assert(q.pop() == true);
   
     // 1, 2, 3, 4
     assert(q.push(1) == true);
     assert(q.push(2) == true);
     assert(q.push(3) == true);
   
     cout << "bottom=" << *q.bottom() << endl; // 3
   
     int tmp = -1;
     q.pop_bottom(&tmp);
     cout << "tmp=" << tmp << endl; // 乱码
   
     return 0;
   }
   编译命令:g++ -o bounded_queue_test bounded_queue_test.cc -lbrpc
   
   运行结果:
   ./bounded_queue_test
   bottom=3
   tmp=-740301056
   
   **Expected behavior (期望行为)**
   
   
   **Versions (各种版本)**
   OS:
   Compiler:
   brpc:
   protobuf:
   
   **Additional context/screenshots (更多上下文/截图)**
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to