|
Boost Users : |
From: Will Bryant (will_at_[hidden])
Date: 2005-11-23 03:50:07
Merrill Cornish wrote:
> I've still got the problem that an illegal option value triggers Dr Watson. I need to create a short example that I can post.
>
Here's one to produce my segfault, which may or may not be the same as
yours:
#include <boost/program_options.hpp>
#include <iostream>
int main(int argc, char* argv[])
{
try
{
boost::program_options::options_description desc("Test");
desc.add_options()("test",
boost::program_options::value<std::string>(),
"import the specified OBJ file and save it to MDLM format");
std::cerr << desc;
return 0;
}
catch (const std::exception& except)
{
std::cerr << except.what() << std::endl;
return 1;
}
}
As per my message the other day, this triggers a bug in
options_description.cpp's format_paragraph function, which causes a
segfault on linux with g++ 4.0.2 (and an assertion failure on Visual
Studio 2005 beta 2); running it under valgrind 2.4.0 on linux produces:
==5197== Memcheck, a memory error detector for x86-linux.
==5197== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==5197== Using valgrind-2.4.0, a program supervision framework for
x86-linux.
==5197== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==5197== For more details, rerun with: -v
==5197==
Test:
--test arg import the specified OBJ file and save it to MDLM
format
==5197== Invalid read of size 2
==5197== at 0x1B9ABB6E:
__gnu_cxx::__pool<true>::_M_reclaim_block(char*, unsigned) (in
/usr/lib/libstdc++.so.6.0.6)
==5197== by 0x804A35C: __gnu_cxx::__mt_alloc<unsigned long,
__gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, true>
>::deallocate(unsigned long*, unsigned) (in /home/will/devel/a.out)
==5197== by 0x804A39B: std::_Bvector_base<std::allocator<bool>
>::_M_deallocate() (in /home/will/devel/a.out)
==5197== by 0x804A3B3: std::_Bvector_base<std::allocator<bool>
>::~_Bvector_base() (in /home/will/devel/a.out)
==5197== by 0x804A40B: std::vector<bool, std::allocator<bool>
>::~vector() (in /home/will/devel/a.out)
==5197== by 0x804A79A:
boost::program_options::options_description::~options_description() (in
/home/will/devel/a.out)
==5197== by 0x8049863: main (in /home/will/devel/a.out)
==5197== Address 0x8 is not stack'd, malloc'd or (recently) free'd
==5197==
==5197== Process terminating with default action of signal 11 (SIGSEGV)
==5197== Access not within mapped region at address 0x8
==5197== at 0x1B9ABB6E:
__gnu_cxx::__pool<true>::_M_reclaim_block(char*, unsigned) (in
/usr/lib/libstdc++.so.6.0.6)
==5197== by 0x804A35C: __gnu_cxx::__mt_alloc<unsigned long,
__gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, true>
>::deallocate(unsigned long*, unsigned) (in /home/will/devel/a.out)
==5197== by 0x804A39B: std::_Bvector_base<std::allocator<bool>
>::_M_deallocate() (in /home/will/devel/a.out)
==5197== by 0x804A3B3: std::_Bvector_base<std::allocator<bool>
>::~_Bvector_base() (in /home/will/devel/a.out)
==5197== by 0x804A40B: std::vector<bool, std::allocator<bool>
>::~vector() (in /home/will/devel/a.out)
==5197== by 0x804A79A:
boost::program_options::options_description::~options_description() (in
/home/will/devel/a.out)
==5197== by 0x8049863: main (in /home/will/devel/a.out)
==5197==
==5197== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 25 from 1)
==5197== malloc/free: in use at exit: 857654 bytes in 79 blocks.
==5197== malloc/free: 81 allocs, 2 frees, 858704 bytes allocated.
==5197== For counts of detected errors, rerun with: -v
==5197== searching for pointers to 79 not-freed blocks.
==5197== checked 1037872 bytes.
==5197==
==5197== LEAK SUMMARY:
==5197== definitely lost: 0 bytes in 0 blocks.
==5197== possibly lost: 8160 bytes in 2 blocks.
==5197== still reachable: 849494 bytes in 77 blocks.
==5197== suppressed: 0 bytes in 0 blocks.
==5197== Reachable blocks (those to which a pointer was found) are not
shown.
==5197== To see them, rerun with: --show-reachable=yes
Segmentation fault
-- Will Bryant http://carcino.gen.nz/ will_at_[hidden] +64 21 655 443
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net