
It appears that there is a problem in token_functions.hpp with probably the *next iterator. It appears to read out of previously freed memory. I recompiled boost with debugging information, and here is the backtrace of boosts invalid memory access's. ==7336== Thread 2: ==7336== Invalid read of size 1 ==7336== at 0x80537C6: _ZN5boost14char_separatorIcSt11char_traitsIcEEclIN9__gnu_cxx17__normal_iteratorIPKcSsEESsEEbRT_SA_RT0_ (token_functions.hpp:305) ==7336== by 0x8053741: boost::token_iterator<boost::char_separator<char, std::char_traits<char> >, __gnu_cxx::__normal_iterator<char const*, std::string>, std::string>::increment() (token_iterator.hpp:55) ==7336== by 0x80536DA: void boost::iterator_core_access::increment<boost::token_iterator<boost::char_separator<char, std::char_traits<char> >, __gnu_cxx::__normal_iterator<char const*, std::string>, std::string> >(boost::token_iterator<boost::char_separator<char, std::char_traits<char> >, __gnu_cxx::__normal_iterator<char const*, std::string>, std::string>&) (iterator_facade.hpp:347) ==7336== by 0x804FC88: boost::iterator_facade<boost::token_iterator<boost::char_separator<char, std::char_traits<char> >, __gnu_cxx::__normal_iterator<char const*, std::string>, std::string>, std::string, boost::forward_traversal_tag, std::string const&, int>::operator++() (iterator_facade.hpp:472) ==7336== by 0x80531E6: Batch<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::getNext(std::string&, std::string&, std::string&) (getNext.cpp:119) ==7336== by 0x805156C: Worker<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::poll() (poll.cpp:29) ==7336== by 0x8050D9A: Worker<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::threadLaunch(void*) (threadLaunch.cpp:16) ==7336== by 0x402E3739: (within /usr/lib/valgrind/libpthread.so) ==7336== by 0x40156395: (within /usr/lib/valgrind/valgrind.so) ==7336== Address 0x41C7F7AD is 57 bytes inside a block of size 240 free'd ==7336== at 0x4002B466: operator delete(void*) (in /usr/lib/valgrind/vgskin_memcheck.so) ==7336== by 0x403AFA96: (within /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403AF3F1: std::__default_alloc_template<true, 0>::deallocate(void*, unsigned) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403AF469: std::allocator<char>::deallocate(char*, unsigned) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403B642A: std::string::_Rep::_M_destroy(std::allocator<char> const&) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403B2FA3: std::string::_Rep::_M_dispose(std::allocator<char> const&) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403B304B: std::string::~string() (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x8051F60: Batch<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::load(PostgresConnection<std::logic_error, std::runtime_error>&) (load.cpp:48) ==7336== by 0x8051496: Worker<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::poll() (poll.cpp:20) ==7336== by 0x8050D9A: Worker<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::threadLaunch(void*) (threadLaunch.cpp:16) ==7336== by 0x402E3739: (within /usr/lib/valgrind/libpthread.so) ==7336== by 0x40156395: (within /usr/lib/valgrind/valgrind.so) ==7336== ==7336== Thread 2: ==7336== Invalid read of size 1 ==7336== at 0x8053825: _ZN5boost14char_separatorIcSt11char_traitsIcEEclIN9__gnu_cxx17__normal_iteratorIPKcSsEESsEEbRT_SA_RT0_ (token_functions.hpp:314) ==7336== by 0x8053741: boost::token_iterator<boost::char_separator<char, std::char_traits<char> >, __gnu_cxx::__normal_iterator<char const*, std::string>, std::string>::increment() (token_iterator.hpp:55) ==7336== by 0x80536DA: void boost::iterator_core_access::increment<boost::token_iterator<boost::char_separator<char, std::char_traits<char> >, __gnu_cxx::__normal_iterator<char const*, std::string>, std::string> >(boost::token_iterator<boost::char_separator<char, std::char_traits<char> >, __gnu_cxx::__normal_iterator<char const*, std::string>, std::string>&) (iterator_facade.hpp:347) ==7336== by 0x804FC88: boost::iterator_facade<boost::token_iterator<boost::char_separator<char, std::char_traits<char> >, __gnu_cxx::__normal_iterator<char const*, std::string>, std::string>, std::string, boost::forward_traversal_tag, std::string const&, int>::operator++() (iterator_facade.hpp:472) ==7336== by 0x80531E6: Batch<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::getNext(std::string&, std::string&, std::string&) (getNext.cpp:119) ==7336== by 0x805156C: Worker<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::poll() (poll.cpp:29) ==7336== by 0x8050D9A: Worker<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::threadLaunch(void*) (threadLaunch.cpp:16) ==7336== by 0x402E3739: (within /usr/lib/valgrind/libpthread.so) ==7336== by 0x40156395: (within /usr/lib/valgrind/valgrind.so) ==7336== Address 0x41C7F7AE is 58 bytes inside a block of size 240 free'd ==7336== at 0x4002B466: operator delete(void*) (in /usr/lib/valgrind/vgskin_memcheck.so) ==7336== by 0x403AFA96: (within /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403AF3F1: std::__default_alloc_template<true, 0>::deallocate(void*, unsigned) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403AF469: std::allocator<char>::deallocate(char*, unsigned) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403B642A: std::string::_Rep::_M_destroy(std::allocator<char> const&) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403B2FA3: std::string::_Rep::_M_dispose(std::allocator<char> const&) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403B304B: std::string::~string() (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x8051F60: Batch<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::load(PostgresConnection<std::logic_error, std::runtime_error>&) (load.cpp:48) ==7336== by 0x8051496: Worker<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::poll() (poll.cpp:20) ==7336== by 0x8050D9A: Worker<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::threadLaunch(void*) (threadLaunch.cpp:16) ==7336== by 0x402E3739: (within /usr/lib/valgrind/libpthread.so) ==7336== by 0x40156395: (within /usr/lib/valgrind/valgrind.so) ==7336== ==7336== Thread 2: ==7336== Invalid read of size 1 ==7336== at 0x805388D: _ZN5boost14char_separatorIcSt11char_traitsIcEEclIN9__gnu_cxx17__normal_iteratorIPKcSsEESsEEbRT_SA_RT0_ (token_functions.hpp:319) ==7336== by 0x8053741: boost::token_iterator<boost::char_separator<char, std::char_traits<char> >, __gnu_cxx::__normal_iterator<char const*, std::string>, std::string>::increment() (token_iterator.hpp:55) ==7336== by 0x80536DA: void boost::iterator_core_access::increment<boost::token_iterator<boost::char_separator<char, std::char_traits<char> >, __gnu_cxx::__normal_iterator<char const*, std::string>, std::string> >(boost::token_iterator<boost::char_separator<char, std::char_traits<char> >, __gnu_cxx::__normal_iterator<char const*, std::string>, std::string>&) (iterator_facade.hpp:347) ==7336== by 0x804FC88: boost::iterator_facade<boost::token_iterator<boost::char_separator<char, std::char_traits<char> >, __gnu_cxx::__normal_iterator<char const*, std::string>, std::string>, std::string, boost::forward_traversal_tag, std::string const&, int>::operator++() (iterator_facade.hpp:472) ==7336== by 0x80531E6: Batch<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::getNext(std::string&, std::string&, std::string&) (getNext.cpp:119) ==7336== by 0x805156C: Worker<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::poll() (poll.cpp:29) ==7336== by 0x8050D9A: Worker<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::threadLaunch(void*) (threadLaunch.cpp:16) ==7336== by 0x402E3739: (within /usr/lib/valgrind/libpthread.so) ==7336== by 0x40156395: (within /usr/lib/valgrind/valgrind.so) ==7336== Address 0x41C7F7AE is 58 bytes inside a block of size 240 free'd ==7336== at 0x4002B466: operator delete(void*) (in /usr/lib/valgrind/vgskin_memcheck.so) ==7336== by 0x403AFA96: (within /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403AF3F1: std::__default_alloc_template<true, 0>::deallocate(void*, unsigned) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403AF469: std::allocator<char>::deallocate(char*, unsigned) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403B642A: std::string::_Rep::_M_destroy(std::allocator<char> const&) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403B2FA3: std::string::_Rep::_M_dispose(std::allocator<char> const&) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403B304B: std::string::~string() (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x8051F60: Batch<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::load(PostgresConnection<std::logic_error, std::runtime_error>&) (load.cpp:48) ==7336== by 0x8051496: Worker<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::poll() (poll.cpp:20) ==7336== by 0x8050D9A: Worker<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::threadLaunch(void*) (threadLaunch.cpp:16) ==7336== by 0x402E3739: (within /usr/lib/valgrind/libpthread.so) ==7336== by 0x40156395: (within /usr/lib/valgrind/valgrind.so) ==7336== ==7336== Thread 2: ==7336== Invalid read of size 1 ==7336== at 0x80538B2: _ZN5boost14char_separatorIcSt11char_traitsIcEEclIN9__gnu_cxx17__normal_iteratorIPKcSsEESsEEbRT_SA_RT0_ (token_functions.hpp:319) ==7336== by 0x8053741: boost::token_iterator<boost::char_separator<char, std::char_traits<char> >, __gnu_cxx::__normal_iterator<char const*, std::string>, std::string>::increment() (token_iterator.hpp:55) ==7336== by 0x80536DA: void boost::iterator_core_access::increment<boost::token_iterator<boost::char_separator<char, std::char_traits<char> >, __gnu_cxx::__normal_iterator<char const*, std::string>, std::string> >(boost::token_iterator<boost::char_separator<char, std::char_traits<char> >, __gnu_cxx::__normal_iterator<char const*, std::string>, std::string>&) (iterator_facade.hpp:347) ==7336== by 0x804FC88: boost::iterator_facade<boost::token_iterator<boost::char_separator<char, std::char_traits<char> >, __gnu_cxx::__normal_iterator<char const*, std::string>, std::string>, std::string, boost::forward_traversal_tag, std::string const&, int>::operator++() (iterator_facade.hpp:472) ==7336== by 0x80531E6: Batch<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::getNext(std::string&, std::string&, std::string&) (getNext.cpp:119) ==7336== by 0x805156C: Worker<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::poll() (poll.cpp:29) ==7336== by 0x8050D9A: Worker<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::threadLaunch(void*) (threadLaunch.cpp:16) ==7336== by 0x402E3739: (within /usr/lib/valgrind/libpthread.so) ==7336== by 0x40156395: (within /usr/lib/valgrind/valgrind.so) ==7336== Address 0x41C7F7AE is 58 bytes inside a block of size 240 free'd ==7336== at 0x4002B466: operator delete(void*) (in /usr/lib/valgrind/vgskin_memcheck.so) ==7336== by 0x403AFA96: (within /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403AF3F1: std::__default_alloc_template<true, 0>::deallocate(void*, unsigned) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403AF469: std::allocator<char>::deallocate(char*, unsigned) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403B642A: std::string::_Rep::_M_destroy(std::allocator<char> const&) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403B2FA3: std::string::_Rep::_M_dispose(std::allocator<char> const&) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403B304B: std::string::~string() (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x8051F60: Batch<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::load(PostgresConnection<std::logic_error, std::runtime_error>&) (load.cpp:48) ==7336== by 0x8051496: Worker<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::poll() (poll.cpp:20) ==7336== by 0x8050D9A: Worker<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::threadLaunch(void*) (threadLaunch.cpp:16) ==7336== by 0x402E3739: (within /usr/lib/valgrind/libpthread.so) ==7336== by 0x40156395: (within /usr/lib/valgrind/valgrind.so) ==7336== ==7336== Thread 2: ==7336== Invalid read of size 1 ==7336== at 0x80538D7: _ZN5boost14char_separatorIcSt11char_traitsIcEEclIN9__gnu_cxx17__normal_iteratorIPKcSsEESsEEbRT_SA_RT0_ (token_functions.hpp:320) ==7336== by 0x8053741: boost::token_iterator<boost::char_separator<char, std::char_traits<char> >, __gnu_cxx::__normal_iterator<char const*, std::string>, std::string>::increment() (token_iterator.hpp:55) ==7336== by 0x80536DA: void boost::iterator_core_access::increment<boost::token_iterator<boost::char_separator<char, std::char_traits<char> >, __gnu_cxx::__normal_iterator<char const*, std::string>, std::string> >(boost::token_iterator<boost::char_separator<char, std::char_traits<char> >, __gnu_cxx::__normal_iterator<char const*, std::string>, std::string>&) (iterator_facade.hpp:347) ==7336== by 0x804FC88: boost::iterator_facade<boost::token_iterator<boost::char_separator<char, std::char_traits<char> >, __gnu_cxx::__normal_iterator<char const*, std::string>, std::string>, std::string, boost::forward_traversal_tag, std::string const&, int>::operator++() (iterator_facade.hpp:472) ==7336== by 0x80531E6: Batch<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::getNext(std::string&, std::string&, std::string&) (getNext.cpp:119) ==7336== by 0x805156C: Worker<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::poll() (poll.cpp:29) ==7336== by 0x8050D9A: Worker<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::threadLaunch(void*) (threadLaunch.cpp:16) ==7336== by 0x402E3739: (within /usr/lib/valgrind/libpthread.so) ==7336== by 0x40156395: (within /usr/lib/valgrind/valgrind.so) ==7336== Address 0x41C7F7AE is 58 bytes inside a block of size 240 free'd ==7336== at 0x4002B466: operator delete(void*) (in /usr/lib/valgrind/vgskin_memcheck.so) ==7336== by 0x403AFA96: (within /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403AF3F1: std::__default_alloc_template<true, 0>::deallocate(void*, unsigned) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403AF469: std::allocator<char>::deallocate(char*, unsigned) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403B642A: std::string::_Rep::_M_destroy(std::allocator<char> const&) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403B2FA3: std::string::_Rep::_M_dispose(std::allocator<char> const&) (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x403B304B: std::string::~string() (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libstdc++.so.5.0.5) ==7336== by 0x8051F60: Batch<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::load(PostgresConnection<std::logic_error, std::runtime_error>&) (load.cpp:48) ==7336== by 0x8051496: Worker<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::poll() (poll.cpp:20) ==7336== by 0x8050D9A: Worker<PostgresConnection<std::logic_error, std::runtime_error>, std::logic_error, std::runtime_error>::threadLaunch(void*) (threadLaunch.cpp:16) ==7336== by 0x402E3739: (within /usr/lib/valgrind/libpthread.so) ==7336== by 0x40156395: (within /usr/lib/valgrind/valgrind.so)

Joshua Moore-Oliva <josh@chatgris.com> writes:
It appears that there is a problem in token_functions.hpp with probably the *next iterator. It appears to read out of previously freed memory.
I recompiled boost with debugging information, and here is the backtrace of boosts invalid memory access's.
Please post a small, complete example that reproduces the problem. -- Dave Abrahams Boost Consulting www.boost-consulting.com

I have found that the problem only occurs when the data to be tokenized goes out of scope... I guess boost doesn't (which is a good thing) copy all the data internally to parse through it. Joshua Moore-Oliva. On April 3, 2004 9:50 am, David Abrahams wrote:
Joshua Moore-Oliva <josh@chatgris.com> writes:
It appears that there is a problem in token_functions.hpp with probably the *next iterator. It appears to read out of previously freed memory.
I recompiled boost with debugging information, and here is the backtrace of boosts invalid memory access's.
Please post a small, complete example that reproduces the problem.
participants (2)
-
David Abrahams
-
Joshua Moore-Oliva