表达式:_BLOCK_TYPE_ISVAILD(pHead->nBlockUse)

发布于 2024-11-12 21:49:21 字数 915 浏览 1 评论 0原文

void Connection::Receive(){
    socket_.async_read_some(boost::asio::buffer(read_buffer_),
          boost::bind(&Connection::handle_Receive, shared_from_this(),boost::asio::placeholders::error));
}

void Connection::handle_Receive(const boost::system::error_code& error)
{
  if(!error)
  {
      if(read_buffer_.size() <=0){
          read_buffer_.empty();
          this->Disconnect();
      }
        ByteBuffer b((std::shared_ptr<uint8_t>)read_buffer_.data(), read_buffer_.size());
        this->OnReceived(b);
        read_buffer_.empty();
  }
//when it loses the if(!error) scope the error pop-up
    }

错误:

Debug Assertion Faild!

Program: D:\C++\Server\Debug\Authsever.exe
File:f:\dd\vctools\crt_bld\self_x86\crt\src\dbgdel.cpp
Expression: _BLOCK_TYPE_ISVAILD(pHead->nBlockUse)

当它失去 if(!error) 范围时,会弹出错误,这个错误是什么意思?!

void Connection::Receive(){
    socket_.async_read_some(boost::asio::buffer(read_buffer_),
          boost::bind(&Connection::handle_Receive, shared_from_this(),boost::asio::placeholders::error));
}

void Connection::handle_Receive(const boost::system::error_code& error)
{
  if(!error)
  {
      if(read_buffer_.size() <=0){
          read_buffer_.empty();
          this->Disconnect();
      }
        ByteBuffer b((std::shared_ptr<uint8_t>)read_buffer_.data(), read_buffer_.size());
        this->OnReceived(b);
        read_buffer_.empty();
  }
//when it loses the if(!error) scope the error pop-up
    }

Error:

Debug Assertion Faild!

Program: D:\C++\Server\Debug\Authsever.exe
File:f:\dd\vctools\crt_bld\self_x86\crt\src\dbgdel.cpp
Expression: _BLOCK_TYPE_ISVAILD(pHead->nBlockUse)

when it loses the if(!error) scope the error pop-up, what is this error means?!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雪落纷纷 2024-11-19 21:49:21

通过将 boost::array 拥有的 uint8_t* 转换为 std::shared_ptr,您会得到双重删除代码>.

    ByteBuffer b((std::shared_ptr<uint8_t>)read_buffer_.data(), read_buffer_.size());
                                        ^^^^^

不要这样做,shared_ptr 用于具有动态存储持续时间的指针。

You are getting a double delete from casting a uint8_t* that is owned by a boost::array<uint8_t,1000> to a std::shared_ptr.

    ByteBuffer b((std::shared_ptr<uint8_t>)read_buffer_.data(), read_buffer_.size());
                                        ^^^^^

Don't do that, a shared_ptr is for pointers with dynamic storage duration.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文