2014-04-01 1 views
0

내 멀티 스레드 프로젝트에서 segfault 오류가 발생했습니다. 이 프로젝트는 연속적으로 실행되어야하는 순환 프로그램으로, 하나 이상의 작업으로 차례로 구성되는 작업을 갖도록 설계되었습니다.Valgrind : 유효하지 않은 크기 4의 읽기, 경계 밖의 segfault 오류

Valgrind를 실행하면 메모리 누수와 범위를 벗어남 (크기가 잘못 읽음) 경고가 나타납니다.

Valgrind의 LOG :

==30039== Memcheck, a memory error detector 
==30039== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al. 
==30039== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info 
==30039== Command: ./sisCAT 
==30039== 
DebugLog: ++++++++++++++ Inicio de Execucao ++++++++++++++++++++++ 
DebugLog: iniciando ciclo do controller 

DebugLog: 3 
==30039== Invalid read of size 4 
==30039== at 0x8081714: SISCAT::TaskCycle::GetTasksByTick(unsigned int, std::vector<SISCAT::Task*, std::allocator<SISCAT::Task*> >&) (TaskCycle.cpp:52) 
==30039== by 0x80783B3: SISCAT::Controller::ExecuteCycle() (Controller.cpp:183) 
==30039== by 0x8078244: SISCAT::Controller::ClockCycle() (Controller.cpp:156) 
==30039== by 0x80781D5: SISCAT::Controller::StartClock() (Controller.cpp:146) 
==30039== by 0x8077B54: SISCAT::Controller::Initialize() (Controller.cpp:129) 
==30039== by 0x807F78C: SISCAT::Controller::Run() (Controller.h:57) 
==30039== by 0x807F71D: SISCAT::SisCAT::run() (SisCAT.cpp:27) 
==30039== by 0x804C8F8: main (boia.cpp:73) 
==30039== Address 0x7355274 is 20 bytes inside a block of size 24 free'd 
==30039== at 0x48D1CFC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) 
==30039== by 0x807D1B2: __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> > >::deallocate(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*, unsigned int) (new_allocator.h:98) 
==30039== by 0x807C3B9: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_put_node(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:373) 
==30039== by 0x807B08B: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_destroy_node(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:395) 
==30039== by 0x807A17F: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_erase(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:1076) 
==30039== by 0x8079564: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::~_Rb_tree() (in /home/lioc/Siscat/sisCAT/Debug/sisCAT) 
==30039== by 0x8078FD6: std::map<std::string, SISCAT::Task*, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::~map() (stl_map.h:88) 
==30039== by 0x80816D0: SISCAT::TaskCycle::GetTasksByTick(unsigned int, std::vector<SISCAT::Task*, std::allocator<SISCAT::Task*> >&) (TaskCycle.cpp:40) 
==30039== by 0x80783B3: SISCAT::Controller::ExecuteCycle() (Controller.cpp:183) 
==30039== by 0x8078244: SISCAT::Controller::ClockCycle() (Controller.cpp:156) 
==30039== by 0x80781D5: SISCAT::Controller::StartClock() (Controller.cpp:146) 
==30039== by 0x8077B54: SISCAT::Controller::Initialize() (Controller.cpp:129) 
==30039== 
==30039== Invalid read of size 4 
==30039== at 0x4984BE5: std::_Rb_tree_increment(std::_Rb_tree_node_base*) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16) 
==30039== by 0x80817A9: SISCAT::TaskCycle::GetTasksByTick(unsigned int, std::vector<SISCAT::Task*, std::allocator<SISCAT::Task*> >&) (TaskCycle.cpp:63) 
==30039== by 0x80783B3: SISCAT::Controller::ExecuteCycle() (Controller.cpp:183) 
==30039== by 0x8078244: SISCAT::Controller::ClockCycle() (Controller.cpp:156) 
==30039== by 0x80781D5: SISCAT::Controller::StartClock() (Controller.cpp:146) 
==30039== by 0x8077B54: SISCAT::Controller::Initialize() (Controller.cpp:129) 
==30039== by 0x807F78C: SISCAT::Controller::Run() (Controller.h:57) 
==30039== by 0x807F71D: SISCAT::SisCAT::run() (SisCAT.cpp:27) 
==30039== by 0x804C8F8: main (boia.cpp:73) 
==30039== Address 0x735526c is 12 bytes inside a block of size 24 free'd 
==30039== at 0x48D1CFC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) 
==30039== by 0x807D1B2: __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> > >::deallocate(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*, unsigned int) (new_allocator.h:98) 
==30039== by 0x807C3B9: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_put_node(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:373) 
==30039== by 0x807B08B: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_destroy_node(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:395) 
==30039== by 0x807A17F: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_erase(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:1076) 
==30039== by 0x8079564: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::~_Rb_tree() (in /home/lioc/Siscat/sisCAT/Debug/sisCAT) 
==30039== by 0x8078FD6: std::map<std::string, SISCAT::Task*, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::~map() (stl_map.h:88) 
==30039== by 0x80816D0: SISCAT::TaskCycle::GetTasksByTick(unsigned int, std::vector<SISCAT::Task*, std::allocator<SISCAT::Task*> >&) (TaskCycle.cpp:40) 
==30039== by 0x80783B3: SISCAT::Controller::ExecuteCycle() (Controller.cpp:183) 
==30039== by 0x8078244: SISCAT::Controller::ClockCycle() (Controller.cpp:156) 
==30039== by 0x80781D5: SISCAT::Controller::StartClock() (Controller.cpp:146) 
==30039== by 0x8077B54: SISCAT::Controller::Initialize() (Controller.cpp:129) 
==30039== 
==30039== Invalid read of size 4 
==30039== at 0x4984BFB: std::_Rb_tree_increment(std::_Rb_tree_node_base*) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16) 
==30039== by 0x80817A9: SISCAT::TaskCycle::GetTasksByTick(unsigned int, std::vector<SISCAT::Task*, std::allocator<SISCAT::Task*> >&) (TaskCycle.cpp:63) 
==30039== by 0x80783B3: SISCAT::Controller::ExecuteCycle() (Controller.cpp:183) 
==30039== by 0x8078244: SISCAT::Controller::ClockCycle() (Controller.cpp:156) 
==30039== by 0x80781D5: SISCAT::Controller::StartClock() (Controller.cpp:146) 
==30039== by 0x8077B54: SISCAT::Controller::Initialize() (Controller.cpp:129) 
==30039== by 0x807F78C: SISCAT::Controller::Run() (Controller.h:57) 
==30039== by 0x807F71D: SISCAT::SisCAT::run() (SisCAT.cpp:27) 
==30039== by 0x804C8F8: main (boia.cpp:73) 
==30039== Address 0x7355264 is 4 bytes inside a block of size 24 free'd 
==30039== at 0x48D1CFC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) 
==30039== by 0x807D1B2: __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> > >::deallocate(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*, unsigned int) (new_allocator.h:98) 
==30039== by 0x807C3B9: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_put_node(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:373) 
==30039== by 0x807B08B: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_destroy_node(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:395) 
==30039== by 0x807A17F: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_erase(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:1076) 
==30039== by 0x8079564: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::~_Rb_tree() (in /home/lioc/Siscat/sisCAT/Debug/sisCAT) 
==30039== by 0x8078FD6: std::map<std::string, SISCAT::Task*, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::~map() (stl_map.h:88) 
==30039== by 0x80816D0: SISCAT::TaskCycle::GetTasksByTick(unsigned int, std::vector<SISCAT::Task*, std::allocator<SISCAT::Task*> >&) (TaskCycle.cpp:40) 
==30039== by 0x80783B3: SISCAT::Controller::ExecuteCycle() (Controller.cpp:183) 
==30039== by 0x8078244: SISCAT::Controller::ClockCycle() (Controller.cpp:156) 
==30039== by 0x80781D5: SISCAT::Controller::StartClock() (Controller.cpp:146) 
==30039== by 0x8077B54: SISCAT::Controller::Initialize() (Controller.cpp:129) 
==30039== 
==30039== Invalid read of size 4 
==30039== at 0x4984C00: std::_Rb_tree_increment(std::_Rb_tree_node_base*) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16) 
==30039== by 0x80817A9: SISCAT::TaskCycle::GetTasksByTick(unsigned int, std::vector<SISCAT::Task*, std::allocator<SISCAT::Task*> >&) (TaskCycle.cpp:63) 
==30039== by 0x80783B3: SISCAT::Controller::ExecuteCycle() (Controller.cpp:183) 
==30039== by 0x8078244: SISCAT::Controller::ClockCycle() (Controller.cpp:156) 
==30039== by 0x80781D5: SISCAT::Controller::StartClock() (Controller.cpp:146) 
==30039== by 0x8077B54: SISCAT::Controller::Initialize() (Controller.cpp:129) 
==30039== by 0x807F78C: SISCAT::Controller::Run() (Controller.h:57) 
==30039== by 0x807F71D: SISCAT::SisCAT::run() (SisCAT.cpp:27) 
==30039== by 0x804C8F8: main (boia.cpp:73) 
==30039== Address 0x73551dc is 12 bytes inside a block of size 24 free'd 
==30039== at 0x48D1CFC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) 
==30039== by 0x807D1B2: __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> > >::deallocate(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*, unsigned int) (new_allocator.h:98) 
==30039== by 0x807C3B9: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_put_node(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:373) 
==30039== by 0x807B08B: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_destroy_node(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:395) 
==30039== by 0x807A17F: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_erase(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:1076) 
==30039== by 0x8079564: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::~_Rb_tree() (in /home/lioc/Siscat/sisCAT/Debug/sisCAT) 
==30039== by 0x8078FD6: std::map<std::string, SISCAT::Task*, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::~map() (stl_map.h:88) 
==30039== by 0x80816D0: SISCAT::TaskCycle::GetTasksByTick(unsigned int, std::vector<SISCAT::Task*, std::allocator<SISCAT::Task*> >&) (TaskCycle.cpp:40) 
==30039== by 0x80783B3: SISCAT::Controller::ExecuteCycle() (Controller.cpp:183) 
==30039== by 0x8078244: SISCAT::Controller::ClockCycle() (Controller.cpp:156) 
==30039== by 0x80781D5: SISCAT::Controller::StartClock() (Controller.cpp:146) 
==30039== by 0x8077B54: SISCAT::Controller::Initialize() (Controller.cpp:129) 
==30039== 
==30039== Invalid read of size 4 
==30039== at 0x4984BF2: std::_Rb_tree_increment(std::_Rb_tree_node_base*) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16) 
==30039== by 0x80817A9: SISCAT::TaskCycle::GetTasksByTick(unsigned int, std::vector<SISCAT::Task*, std::allocator<SISCAT::Task*> >&) (TaskCycle.cpp:63) 
==30039== by 0x80783B3: SISCAT::Controller::ExecuteCycle() (Controller.cpp:183) 
==30039== by 0x8078244: SISCAT::Controller::ClockCycle() (Controller.cpp:156) 
==30039== by 0x80781D5: SISCAT::Controller::StartClock() (Controller.cpp:146) 
==30039== by 0x8077B54: SISCAT::Controller::Initialize() (Controller.cpp:129) 
==30039== by 0x807F78C: SISCAT::Controller::Run() (Controller.h:57) 
==30039== by 0x807F71D: SISCAT::SisCAT::run() (SisCAT.cpp:27) 
==30039== by 0x804C8F8: main (boia.cpp:73) 
==30039== Address 0x7355220 is 8 bytes inside a block of size 24 free'd 
==30039== at 0x48D1CFC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) 
==30039== by 0x807D1B2: __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> > >::deallocate(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*, unsigned int) (new_allocator.h:98) 
==30039== by 0x807C3B9: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_put_node(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:373) 
==30039== by 0x807B08B: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_destroy_node(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:395) 
==30039== by 0x807A17F: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_erase(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:1076) 
==30039== by 0x807A15F: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_erase(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:1074) 
==30039== by 0x8079564: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::~_Rb_tree() (in /home/lioc/Siscat/sisCAT/Debug/sisCAT) 
==30039== by 0x8078FD6: std::map<std::string, SISCAT::Task*, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::~map() (stl_map.h:88) 
==30039== by 0x80816D0: SISCAT::TaskCycle::GetTasksByTick(unsigned int, std::vector<SISCAT::Task*, std::allocator<SISCAT::Task*> >&) (TaskCycle.cpp:40) 
==30039== by 0x80783B3: SISCAT::Controller::ExecuteCycle() (Controller.cpp:183) 
==30039== by 0x8078244: SISCAT::Controller::ClockCycle() (Controller.cpp:156) 
==30039== by 0x80781D5: SISCAT::Controller::StartClock() (Controller.cpp:146) 
==30039== 
==30039== Invalid read of size 4 
==30039== at 0x4984C12: std::_Rb_tree_increment(std::_Rb_tree_node_base*) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16) 
==30039== by 0x80817A9: SISCAT::TaskCycle::GetTasksByTick(unsigned int, std::vector<SISCAT::Task*, std::allocator<SISCAT::Task*> >&) (TaskCycle.cpp:63) 
==30039== by 0x80783B3: SISCAT::Controller::ExecuteCycle() (Controller.cpp:183) 
==30039== by 0x8078244: SISCAT::Controller::ClockCycle() (Controller.cpp:156) 
==30039== by 0x80781D5: SISCAT::Controller::StartClock() (Controller.cpp:146) 
==30039== by 0x8077B54: SISCAT::Controller::Initialize() (Controller.cpp:129) 
==30039== by 0x807F78C: SISCAT::Controller::Run() (Controller.h:57) 
==30039== by 0x807F71D: SISCAT::SisCAT::run() (SisCAT.cpp:27) 
==30039== by 0x804C8F8: main (boia.cpp:73) 
==30039== Address 0x73551d4 is 4 bytes inside a block of size 24 free'd 
==30039== at 0x48D1CFC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) 
==30039== by 0x807D1B2: __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> > >::deallocate(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*, unsigned int) (new_allocator.h:98) 
==30039== by 0x807C3B9: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_put_node(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:373) 
==30039== by 0x807B08B: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_destroy_node(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:395) 
==30039== by 0x807A17F: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_erase(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:1076) 
==30039== by 0x8079564: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::~_Rb_tree() (in /home/lioc/Siscat/sisCAT/Debug/sisCAT) 
==30039== by 0x8078FD6: std::map<std::string, SISCAT::Task*, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::~map() (stl_map.h:88) 
==30039== by 0x80816D0: SISCAT::TaskCycle::GetTasksByTick(unsigned int, std::vector<SISCAT::Task*, std::allocator<SISCAT::Task*> >&) (TaskCycle.cpp:40) 
==30039== by 0x80783B3: SISCAT::Controller::ExecuteCycle() (Controller.cpp:183) 
==30039== by 0x8078244: SISCAT::Controller::ClockCycle() (Controller.cpp:156) 
==30039== by 0x80781D5: SISCAT::Controller::StartClock() (Controller.cpp:146) 
==30039== by 0x8077B54: SISCAT::Controller::Initialize() (Controller.cpp:129) 
==30039== 
==30039== Invalid read of size 4 
==30039== at 0x4984C1A: std::_Rb_tree_increment(std::_Rb_tree_node_base*) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16) 
==30039== by 0x80817A9: SISCAT::TaskCycle::GetTasksByTick(unsigned int, std::vector<SISCAT::Task*, std::allocator<SISCAT::Task*> >&) (TaskCycle.cpp:63) 
==30039== by 0x80783B3: SISCAT::Controller::ExecuteCycle() (Controller.cpp:183) 
==30039== by 0x8078244: SISCAT::Controller::ClockCycle() (Controller.cpp:156) 
==30039== by 0x80781D5: SISCAT::Controller::StartClock() (Controller.cpp:146) 
==30039== by 0x8077B54: SISCAT::Controller::Initialize() (Controller.cpp:129) 
==30039== by 0x807F78C: SISCAT::Controller::Run() (Controller.h:57) 
==30039== by 0x807F71D: SISCAT::SisCAT::run() (SisCAT.cpp:27) 
==30039== by 0x804C8F8: main (boia.cpp:73) 
==30039== Address 0x73551dc is 12 bytes inside a block of size 24 free'd 
==30039== at 0x48D1CFC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) 
==30039== by 0x807D1B2: __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> > >::deallocate(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*, unsigned int) (new_allocator.h:98) 
==30039== by 0x807C3B9: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_put_node(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:373) 
==30039== by 0x807B08B: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_destroy_node(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:395) 
==30039== by 0x807A17F: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::_M_erase(std::_Rb_tree_node<std::pair<std::string const, SISCAT::Task*> >*) (stl_tree.h:1076) 
==30039== by 0x8079564: std::_Rb_tree<std::string, std::pair<std::string const, SISCAT::Task*>, std::_Select1st<std::pair<std::string const, SISCAT::Task*> >, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::~_Rb_tree() (in /home/lioc/Siscat/sisCAT/Debug/sisCAT) 
==30039== by 0x8078FD6: std::map<std::string, SISCAT::Task*, std::less<std::string>, std::allocator<std::pair<std::string const, SISCAT::Task*> > >::~map() (stl_map.h:88) 
==30039== by 0x80816D0: SISCAT::TaskCycle::GetTasksByTick(unsigned int, std::vector<SISCAT::Task*, std::allocator<SISCAT::Task*> >&) (TaskCycle.cpp:40) 
==30039== by 0x80783B3: SISCAT::Controller::ExecuteCycle() (Controller.cpp:183) 
==30039== by 0x8078244: SISCAT::Controller::ClockCycle() (Controller.cpp:156) 
==30039== by 0x80781D5: SISCAT::Controller::StartClock() (Controller.cpp:146) 
==30039== by 0x8077B54: SISCAT::Controller::Initialize() (Controller.cpp:129) 
==30039== 
==30039== Use of uninitialised value of size 4 
==30039== at 0x8081E99: SISCAT::Task::GetTickExecution() (Task.h:121) 
==30039== by 0x808171E: SISCAT::TaskCycle::GetTasksByTick(unsigned int, std::vector<SISCAT::Task*, std::allocator<SISCAT::Task*> >&) (TaskCycle.cpp:52) 
==30039== by 0x80783B3: SISCAT::Controller::ExecuteCycle() (Controller.cpp:183) 
==30039== by 0x8078244: SISCAT::Controller::ClockCycle() (Controller.cpp:156) 
==30039== by 0x80781D5: SISCAT::Controller::StartClock() (Controller.cpp:146) 
==30039== by 0x8077B54: SISCAT::Controller::Initialize() (Controller.cpp:129) 
==30039== by 0x807F78C: SISCAT::Controller::Run() (Controller.h:57) 
==30039== by 0x807F71D: SISCAT::SisCAT::run() (SisCAT.cpp:27) 
==30039== by 0x804C8F8: main (boia.cpp:73) 
==30039== 
==30039== Invalid read of size 4 
==30039== at 0x8081E99: SISCAT::Task::GetTickExecution() (Task.h:121) 
==30039== by 0x808171E: SISCAT::TaskCycle::GetTasksByTick(unsigned int, std::vector<SISCAT::Task*, std::allocator<SISCAT::Task*> >&) (TaskCycle.cpp:52) 
==30039== by 0x80783B3: SISCAT::Controller::ExecuteCycle() (Controller.cpp:183) 
==30039== by 0x8078244: SISCAT::Controller::ClockCycle() (Controller.cpp:156) 
==30039== by 0x80781D5: SISCAT::Controller::StartClock() (Controller.cpp:146) 
==30039== by 0x8077B54: SISCAT::Controller::Initialize() (Controller.cpp:129) 
==30039== by 0x807F78C: SISCAT::Controller::Run() (Controller.h:57) 
==30039== by 0x807F71D: SISCAT::SisCAT::run() (SisCAT.cpp:27) 
==30039== by 0x804C8F8: main (boia.cpp:73) 
==30039== Address 0x13 is not stack'd, malloc'd or (recently) free'd 
==30039== 
==30039== Process terminating with default action of signal 11 (SIGSEGV) 
==30039== Access not within mapped region at address 0x13 
==30039== at 0x8081E99: SISCAT::Task::GetTickExecution() (Task.h:121) 
==30039== by 0x808171E: SISCAT::TaskCycle::GetTasksByTick(unsigned int, std::vector<SISCAT::Task*, std::allocator<SISCAT::Task*> >&) (TaskCycle.cpp:52) 
==30039== by 0x80783B3: SISCAT::Controller::ExecuteCycle() (Controller.cpp:183) 
==30039== by 0x8078244: SISCAT::Controller::ClockCycle() (Controller.cpp:156) 
==30039== by 0x80781D5: SISCAT::Controller::StartClock() (Controller.cpp:146) 
==30039== by 0x8077B54: SISCAT::Controller::Initialize() (Controller.cpp:129) 
==30039== by 0x807F78C: SISCAT::Controller::Run() (Controller.h:57) 
==30039== by 0x807F71D: SISCAT::SisCAT::run() (SisCAT.cpp:27) 
==30039== by 0x804C8F8: main (boia.cpp:73) 
==30039== If you believe this happened as a result of a stack 
==30039== overflow in your program's main thread (unlikely but 
==30039== possible), you can try to increase the size of the 
==30039== main thread stack using the --main-stacksize= flag. 
==30039== The main thread stack size used in this run was 8388608. 
==30039== 
==30039== HEAP SUMMARY: 
==30039==  in use at exit: 10,856 bytes in 183 blocks 
==30039== total heap usage: 237 allocs, 54 frees, 14,287 bytes allocated 
==30039== 
==30039== LEAK SUMMARY: 
==30039== definitely lost: 4,164 bytes in 2 blocks 
==30039== indirectly lost: 53 bytes in 2 blocks 
==30039==  possibly lost: 2,427 bytes in 93 blocks 
==30039== still reachable: 4,212 bytes in 86 blocks 
==30039==   suppressed: 0 bytes in 0 blocks 
==30039== Rerun with --leak-check=full to see details of leaked memory 
==30039== 
==30039== For counts of detected and suppressed errors, rerun with: -v 
==30039== Use --track-origins=yes to see where uninitialised values come from 
==30039== ERROR SUMMARY: 15 errors from 9 contexts (suppressed: 0 from 0) 
Segmentation fault 
이 보고서에 포함 된 기능과 클래스의

부품은 다음과 같습니다 :이 TaskID를 문자열 타입 작업 클래스의 생성자가

RETURN::Return_t TaskCycle::GetTasksByTick(uint32_t tick, 
     std::vector<Task*>& Tasks) 
{ 
    Tasks.clear(); 
    if (GetTasks().empty()) 
     return RETURN::ERROR_UPDATING_TASK; 
    Task* task; 
    std::map<TaskID, Task*>::iterator iter = GetTasks().begin(); 
    while (iter != GetTasks().end()) 
    { 
     if (iter->second->GetTickExecution()== tick) **// Line: 52** 
     { 
      task = iter->second; 
      if(task->CanExecute()) 
      { 
      Tasks.push_back(task); 
      } 
     } 
     iter++;          **// Line: 63** 
    } 
    return RETURN::OK; 
} 

uint32_t Task::GetTickExecution() 
    { 
     return m_tickExecution; 
    } 

:

Task(TaskID name, uint32_t m_tickOffSet, uint32_t m_tickInterval, 
      uint32_t m_executionsPerCycle, TaskPriority::TaskPriority_t m_prio, 
      std::map<OperationID, Operation*> m_registeredOperations) : 
     m_name(name), m_tickOffSet(m_tickOffSet), 
       m_tickInterval(m_tickInterval), 
       m_executionsPerCycle(m_executionsPerCycle), m_prio(m_prio), 
       m_registeredOperations(m_registeredOperations) 

오류가보고되는 방법은 그냥 Get 메서드이며, 부호없는 int 변수.

+0

만약 멀티 스레딩이 책임이 있다고 생각되면,'valgrind --tool = helgrind'를 통해 프로그램을 실행하십시오. 프로그램에는 수많은 메모리 오류가 있으며,이 중 하나 하나는 정의되지 않은 동작을 구성하며 다른 모든 오류를 담당 할 수 있습니다. 선호하는 모든 것을 하나씩 제거해야합니다. –

+0

@mic_e 실행 helgrind 도구 : [코드] 신호의 기본 동작도 11의 (SIGSEGV) == == 30,119 30,119 == 0x8078F65에서 어드레스 0x547C20AA ==에 매핑되지 영역 내의 통로와 종료 프로세스 : 작업 SISCAT :: :: CanExecute() (Task.h : 104) == 30119 == 0x8081774 : SISCAT :: TaskCycle :: GetTasksByTick (unsigned int, std :: vector >> &) (TaskCycle.cpp : 58) ... [code] – lfelipem

+0

제 경험상 valgrind는 segfaults를 디버깅하는 데별로 유용하지 않습니다. 프로그램이 여전히 올바르게 작동 하는지를 주기적으로 확인해야하지만, segfault가 있으면 gdb를 사용해야합니다. @lfelipem : 그래서 helgrind가 오류를 찾지 못했습니까? 그건 안심 이군. –

답변

0

그럼 정확히 무엇이 당신의 질문입니까?

파일 이름과 줄 번호를 코드에 게시하면 사람이 코드를 valgrind 출력의 줄 번호와 일치시킬 수 있습니다.

==30039== Invalid read of size 4 
==30039== at 0x8081714: SISCAT::TaskCycle::GetTasksByTick(unsigned int, std::vector<SISCAT::Task*, std::allocator<SISCAT::Task*> >&) (TaskCycle.cpp:52) 

은 아마 당신이 줄 번호 (52)에 널 포인터 또는 초기화되지 포인터를 액세스하는, 그리고 매우 많은이

==30039== Invalid read of size 4 
==30039== at 0x4984BE5: std::_Rb_tree_increment(std::_Rb_tree_node_base*) (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.16) 
==30039== by 0x80817A9: SISCAT::TaskCycle::GetTasksByTick(unsigned int, std::vector<SISCAT::Task*, std::allocator<SISCAT::Task*> >&) (TaskCycle.cpp:63) 

힌트가 널 포인터를 전달하는 의미 ~ std::_Rb_tree_increment. 그러나 TaskCycle.cpp에서 52 번째 줄과 63 번째 줄을 볼 수 없기 때문에 그다지 도움이되지 못합니다.

만약 내가 당신이라면 나는 디버거를 사용하거나 valgrind에 의해보고 된 모든 행 번호에 printf("xxx=%p\n", xxx)과 같은 것을 추가합니다 (xxx를 해당 행에 사용 된 모든 포인터로 바꿉니다) 잘못된 것 같습니다.

+0

내가 언급 한 코드로 코드를 편집했지만 모든 라인에 번호를 매길 수는 없었습니다. – lfelipem

+0

포인터를 인쇄하려고 할 때 == 30250 == 조건부 점프 또는 이동은 초기화되지 않은 값에 따라 달라집니다. == 30250 == 0x6FEBC70 : vfprintf (vfprintf.c : 1629) == 30250 == 0x6FF2EFE : printf (printf.c : 35) == 30250 == by 0x80783B3 : SISCAT :: Controller :: ExecuteCycle() (Controller.cpp : 183) == 30250 == by 0x8078244 : SISCAT :: Controller :: StartClock() (Controller.cpp : 146) == 30250 SISCAT :: Controller :: ClockClass() (Controller.cpp : 156) == 30250 == == by 0x8077B54 : SISCAT :: Controller :: Initialize() (Controller.cpp : 129) ... – lfelipem

+0

그러면 'iter'에 문제가있을 가능성이 큽니다. gdb를 실행하고, 52 행에 중단 점을 넣고, 중단 점에 도달하면,'print iter','print * iter','print iter-> second'를 알아 차릴 때까지. GetTasks(). begin()이 NULL을 반환하는지 검사하지 않습니다. 유효한 iterator를 반환하지 않을 가능성이 있습니까? –