stxxl 断言 'it != root_node_.end()' 失败
stxxl Assertion `it != root_node_.end()' failed
我在尝试在stxxl映射中插入元素时收到此断言失败错误。
整个断言错误如下:
resCache:/usr/include/stxxl/bits/containers/btree/btree.h:470:std::pair>,bool>stxxl::btree::btree::insert(const value_type&)[with KeyType=e_my_key,DataType=unsigned int,CompareType=comp_type,unsigned int-RawNodeSize=16384u,unsignedint-RawLeafSize=131072u,PDAllocStrategy=stxxl:::SR,stxxl::btree=:btree]:断言`it!=root_node_.end()'失败。中止
知道吗?
编辑:这是的代码片段
void request_handler::handle_request(my_key& query, reply& rep)
{
c_++;
std::cout << "Received query " << query.content << " by thread " << boost::this_thread::get_id() << ". It is number " << c_ << "n";
strcpy(element.first.content, query.content);
element.second = c_;
testcache_.insert(element);
STXXL_MSG("Records in map: " << testcache_.size());
}
Edit2这里有更多的细节(我省略了常量,例如MAX_QUERY_LEN)
struct comp_type : std::binary_function<my_key, my_key, bool>
{
bool operator () (const my_key & a, const my_key & b) const
{
return strncmp(a.content, b.content, MAX_QUERY_LEN) < 0;
}
static my_key max_value()
{
return max_key;
}
static my_key min_value()
{
return min_key;
}
};
typedef stxxl::map<my_key, my_data, comp_type> cacheType;
cacheType testcache_;
request_handler::request_handler()
:testcache_(NODE_CACHE_SIZE, LEAF_CACHE_SIZE)
{
c_ = 0;
memset(max_key.content, (std::numeric_limits<unsigned char>::max)(), MAX_QUERY_LEN);
memset(min_key.content, (std::numeric_limits<unsigned char>::min)(), MAX_QUERY_LEN);
testcache_.enable_prefetching();
STXXL_MSG("Records in map: " << testcache_.size());
}
这里有一个想法:使用valgrind。在诊断程序中可能存在的非本地错误时,它通常非常有用。也就是说,您可能在某个地方损坏了容器(一个常见的错误是在迭代时擦除)。因此,失败的断言可能是由于您对容器做了一些错误,但可能不是在程序终止之前。Valgrind可以帮助您查找无效的内存访问等等。
相关文章:
- 来自 std::list 的迭代器 .end() 按预期返回"0xcdcdcdcdcdcdcdcd"但 .begin()
- std::map<struct,struct>::find 找不到匹配项,但是如果我循环通过 begin() 到 end(),我在那里看到匹配项
- node-gyp 在 macOS 上未正确链接库
- 为什么C++对链表中的下一个节点使用指针,而像 C# 或 Java 这样的语言只使用类 Node 的名称?
- node-gyp 的先有鸡还是先有蛋的问题:指向依赖项中的头文件
- 反转依赖于 end() 的迭代器
- std::multimap<std::chrono::milliseconds, T>::rbegin 在 MSVS-13 中指向 end()?
- 在C++中使用 Catch 测试框架编译错误"error: expected ';' at end of declaration list"
- remove(str.begin(), str.end(), );无法正常工作(我正在使用视觉工作室 2012)
- 在 ifcondition al中 find() C++ STL 中的 == a.end() 有什么用?
- 在 ubuntu 上安装 node js pulsar 客户端
- 野牛/yacc 解析器在不被空格分隔时跳过 grammer - "unexpected $end"
- "错误 C0000:语法错误,令牌"<EOF>"处出现意外$end,并且不确定
- 如何使用 Node-addon-API 实现 node-nan 回调
- 了解向量中的 .begin 和 .end
- Node.js fs.open() 在尝试打开 4 个以上的命名管道 (FIFO) 后挂起
- NodeJS:node-gyp 编译与等效的 gcc -lm 选项
- 如何实现链表的 end()?
- 使用 map.end() 访问 map 的最后一个元素
- 调用'Node'构造函数是不明确的