2012-07-08 4 views
2

부스터/파일 시스템을 사용하여 디렉토리를 반복하고 MacOSX + XCode3의 Zip 파일에 추가합니다.부스트 directory_iterator SIGABRT 수신

내 원래의 논리는 것 같아요, directory_iterator의 소멸자가 호출 특별히 할 때, 문제는이 기능을 반환 한 후에 발생이

path targetDir("Volumes/data/some_directory"); 
directory_iterator it(targetDir), eod; 

std::string filename; 
std::string strPath; 

// I tried both of two types of making loop 
for(; it != eod ; ++it) 
{ 
    path const& p = *it; 
    filename = p.filename(); 
    if(is_directory(p)) 
    { 
     strPath = strDirectory + filename + string("/"); 

     // Initially I wanted this logic to be recursive(these code block is a part of PackDirectory) 
     PackDirectory(archive, strPath, lpszPackFile); 
    } 
    else if(is_regular_file(p)) 
    { 
     strPath = strDirectory + filename; 
     // add this file to specified Zip file here 
    } 

} 

then function returns here. 

것 같습니다. 잘못된 포인터를 삭제하고 SIGABRT를받는 것 같습니다. 프로그램이 때때로 아래와 같이 충돌하고 단계를 넘기면 때때로 멈추고 Xcode는 "넘어서고 있습니다"라고 말하지만 아무것도 사라지는 호출 스택이 진행되지 않습니다. 요점은 루프 내에서 아무 것도하지 않더라도 변수가 단순히 생성되고 함수가 반환 될 때 문제가 발생한다는 것입니다.

자세한 내용은 프로그램 충돌시 호출 스택 모양을 참조하십시오.

#0 0x93f86c5a in __kill 
#1 0x93f86c4c in kill$UNIX2003 
#2 0x940195a5 in raise 
#3 0x9402f6e4 in abort 
#4 0x93f2c575 in free 
#5 0x00134aea in dir_itr_close [inlined] at v2_operations.cpp:1300 
#6 0x00134aea in ~dir_itr_imp [inlined] at operations.hpp:877 
#7 0x00134aea in  checked_delete<boost::filesystem2::detail::dir_itr_imp<boost::filesystem2::basic_path<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::filesystem2::path_traits> > > [inlined] at checked_delete.hpp:34 
#8 0x00134aea in boost::detail::sp_counted_impl_p<boost::filesystem2::detail::dir_itr_imp<boost::filesystem2::basic_path<std::string, boost::filesystem2::path_traits> > >::dispose at v2_operations.cpp:78 
#9 0x00136583 in boost::detail::sp_counted_base::weak_release at sp_counted_base_pt.hpp:97 

~ dir_itr_imp에 들어가서 형식 검사를 통과 한 후 올바른 소멸자에 도달하는 것 같습니다.

directory_iterator에 문제가 있습니까? 누군가이 문제를 겪었 으면 알려주세요.

답변

0

free에서 발생한 신호가 호출 기능의 결함을 가리키는 것은 아닙니다. free에 대한 이전/깨진 전화가 malloc의 사용 가능한 메모리 목록을 손상시킬 수 있으며 이로 인해 오류가 발생했습니다.

valgrind에서 프로그램을 실행 해보십시오.이 프로그램은 더 강력하며 손상된 메모리 할당/할당 취소가 사용되는 즉시 죽습니다. valgrind 옵션이 아닌 경우 나머지 프로그램과 독립적으로 단위 테스트에서 코드를 테스트 할 수도 있습니다.

+0

Xcode 버그였습니다. 일부 중단 점은 실제 디버깅 행과 다르기 때문에 directory_iterator를 두 번 삭제합니다. 내 XCode를 4.2로 업데이트하고 있습니다. 도움 주셔서 감사합니다, btw :) – extremer

관련 문제