2012-03-22 4 views
0

stxxl 맵에 요소를 삽입 할 때이 어설 션에 실패했습니다.stxxl 어설 션`it! = root_node_.end() '가 실패했습니다

resCache : /usr/include/stxxl/bits/containers/btree/btree.h:470 : 표준 : : 쌍>, 부울> stxxl ::

전체 어설 션 오류는 다음이다 btree :: btree :: insert (const value_type &) [KeyType = e_my_key, DataType = 부호없는 int, CompareType = comp_type, 부호없는 int RawNodeSize = 16384u, 부호없는 int RawLeafSize = 131072u, PDAllocStrategy = stxxl :: SR, stxxl :: btree :: btree :: value_type = std :: pair] : 어설 션`it! = root_node_.end() '가 실패했습니다. 중단됨

어떤 아이디어가 있습니까?

편집 : 사용 Valgrind의 : 여기

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()); 
} 
+0

코드에서 코드 라인이 어설 션을 트리거합니까? 어떻게 요소를 삽입하려고합니까? – sth

+0

코드를 게시 할 수 있습니까? – hmjd

+0

'testcache_'와 다른 비교기의 선언을 게시 할 수 있습니까? – hmjd

답변

0

가 여기에 생각입니다. 프로그램에서 비정상적인 버그가 무엇인지 진단 할 때 종종 매우 유용합니다. 즉, 도중에 컨테이너를 손상시킬 수 있습니다 (반복되는 동안 일반적인 실수가 지워집니다). 그래서 실패한 주장은 당신이 컨테이너에 뭔가 잘못한 것이 원인 일 가능성이 높습니다. 그러나 프로그램이 죽기 직전이 아닐 수도 있습니다. Valgrind는 잘못된 메모리 액세스 등을 찾는 데 도움을 줄 수 있습니다.

+0

valgrind가 도움이되지 않습니다. 나는 그것을 시도했고 그것은 나에게 어떤 오류도주지 않는다. :( –