stxxl 断言 'it != root_node_.end()' 失败

stxxl Assertion `it != root_node_.end()' failed

本文关键字:node end 失败 断言 it stxxl root      更新时间:2023-10-16

我在尝试在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可以帮助您查找无效的内存访问等等。