Skip to content

Instantly share code, notes, and snippets.

@tomsmeding
Last active October 3, 2018 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomsmeding/ff4e77f181ff6d87c5bcf03531701435 to your computer and use it in GitHub Desktop.
Save tomsmeding/ff4e77f181ff6d87c5bcf03531701435 to your computer and use it in GitHub Desktop.
gcc bug priority_queue multiple files same struct name
$ valgrind ./ab
==13981== Memcheck, a memory error detector
==13981== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==13981== Using Valgrind-3.14.0.GIT and LibVEX; rerun with -h for copyright info
==13981== Command: ./ab
==13981==
==13981==
==13981== HEAP SUMMARY:
==13981== in use at exit: 0 bytes in 0 blocks
==13981== total heap usage: 2 allocs, 2 frees, 72,708 bytes allocated
==13981==
==13981== All heap blocks were freed -- no leaks are possible
==13981==
==13981== For counts of detected and suppressed errors, rerun with: -v
==13981== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
$ valgrind ./ba
==13982== Memcheck, a memory error detector
==13982== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==13982== Using Valgrind-3.14.0.GIT and LibVEX; rerun with -h for copyright info
==13982== Command: ./ba
==13982==
==13982== Invalid read of size 8
==13982== at 0x10954A: void std::push_heap<__gnu_cxx::__normal_iterator<Event*, std::vector<Event, std::allocator<Event> > >, std::less<Event> >(__gnu_cxx::__normal_iterator<Event*, std::vector<Event, std::allocator<Event> > >, __gnu_cxx::__normal_iterator<Event*, std::vector<Event, std::allocator<Event> > >, std::less<Event>) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x10A42B: std::priority_queue<Event, std::vector<Event, std::allocator<Event> >, std::less<Event> >::push(Event const&) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x10A35D: external_insert(std::priority_queue<Event, std::vector<Event, std::allocator<Event> >, std::less<Event> >&, Event) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x10A397: main (in /home/tom/univ/MADS/project/sim/ba)
==13982== Address 0x4d8cc7c is 4 bytes before a block of size 8 alloc'd
==13982== at 0x4837DEF: operator new(unsigned long) (vg_replace_malloc.c:334)
==13982== by 0x10A109: __gnu_cxx::new_allocator<Event>::allocate(unsigned long, void const*) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x10A015: std::allocator_traits<std::allocator<Event> >::allocate(std::allocator<Event>&, unsigned long) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x109EC3: std::_Vector_base<Event, std::allocator<Event> >::_M_allocate(unsigned long) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x10A578: void std::vector<Event, std::allocator<Event> >::_M_realloc_insert<Event const&>(__gnu_cxx::__normal_iterator<Event*, std::vector<Event, std::allocator<Event> > >, Event const&) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x10A4AB: std::vector<Event, std::allocator<Event> >::push_back(Event const&) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x10A405: std::priority_queue<Event, std::vector<Event, std::allocator<Event> >, std::less<Event> >::push(Event const&) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x10A35D: external_insert(std::priority_queue<Event, std::vector<Event, std::allocator<Event> >, std::less<Event> >&, Event) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x10A397: main (in /home/tom/univ/MADS/project/sim/ba)
==13982==
==13982== Invalid write of size 8
==13982== at 0x10991F: void std::__push_heap<__gnu_cxx::__normal_iterator<Event*, std::vector<Event, std::allocator<Event> > >, long, Event, __gnu_cxx::__ops::_Iter_comp_val<std::less<Event> > >(__gnu_cxx::__normal_iterator<Event*, std::vector<Event, std::allocator<Event> > >, long, long, Event, __gnu_cxx::__ops::_Iter_comp_val<std::less<Event> >&) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x109591: void std::push_heap<__gnu_cxx::__normal_iterator<Event*, std::vector<Event, std::allocator<Event> > >, std::less<Event> >(__gnu_cxx::__normal_iterator<Event*, std::vector<Event, std::allocator<Event> > >, __gnu_cxx::__normal_iterator<Event*, std::vector<Event, std::allocator<Event> > >, std::less<Event>) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x10A42B: std::priority_queue<Event, std::vector<Event, std::allocator<Event> >, std::less<Event> >::push(Event const&) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x10A35D: external_insert(std::priority_queue<Event, std::vector<Event, std::allocator<Event> >, std::less<Event> >&, Event) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x10A397: main (in /home/tom/univ/MADS/project/sim/ba)
==13982== Address 0x4d8cc78 is 8 bytes before a block of size 8 alloc'd
==13982== at 0x4837DEF: operator new(unsigned long) (vg_replace_malloc.c:334)
==13982== by 0x10A109: __gnu_cxx::new_allocator<Event>::allocate(unsigned long, void const*) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x10A015: std::allocator_traits<std::allocator<Event> >::allocate(std::allocator<Event>&, unsigned long) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x109EC3: std::_Vector_base<Event, std::allocator<Event> >::_M_allocate(unsigned long) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x10A578: void std::vector<Event, std::allocator<Event> >::_M_realloc_insert<Event const&>(__gnu_cxx::__normal_iterator<Event*, std::vector<Event, std::allocator<Event> > >, Event const&) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x10A4AB: std::vector<Event, std::allocator<Event> >::push_back(Event const&) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x10A405: std::priority_queue<Event, std::vector<Event, std::allocator<Event> >, std::less<Event> >::push(Event const&) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x10A35D: external_insert(std::priority_queue<Event, std::vector<Event, std::allocator<Event> >, std::less<Event> >&, Event) (in /home/tom/univ/MADS/project/sim/ba)
==13982== by 0x10A397: main (in /home/tom/univ/MADS/project/sim/ba)
==13982==
==13982==
==13982== HEAP SUMMARY:
==13982== in use at exit: 0 bytes in 0 blocks
==13982== total heap usage: 2 allocs, 2 frees, 72,712 bytes allocated
==13982==
==13982== All heap blocks were freed -- no leaks are possible
==13982==
==13982== For counts of detected and suppressed errors, rerun with: -v
==13982== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment