Boost logo

Boost Users :

From: Matt Schuckmann (matt_at_[hidden])
Date: 2006-09-07 16:27:40


At some point many of my applications that use the boost.program_options
libraries started crashing when they attempt to print the options
descriptions
i.e.
cout << opt_desc;

I believe the problem started when we upgraded to boost 1.33.1 from
1.32.0 and were using MSVC 7.1.
I'm not trying to figure out the problem using boost 1.33.1 using MSVC 8.0.

Here is the deal if I run the debug version of one of my apps with the
standard --help option it runs fine. If I run the release version part
of the help message is displayed but then the application crashes

If I attempt to debug the problem by launching the debug version of
application from the MS debugger I get a debug assertion failed in
xstring in a _SCL_SECURE_VALIDATE_RANGE check on operator += (basically
the new secure checked iterators MS had introduced are complaining about
  an out of range iterator). Looking at the call stack the problem
stemmed from line 361 of options_description.cpp (the format_paragraph
function).

Basically it looks like the program_options library is running afoul of
the new checked iterators in MSVC 8.0 but since I do know we experienced
  a problem in using MSVC7.1 I think the problem is more insidious than
a boundary condition check is overstepping an iterator range.

Has anybody else experienced this type of problem or have any idea's on
how to fix it?

Thanks
Matt S.

FYI here is the start of my main including my add_options, store, and
notify calls and the call to display the help message.

o::options_description options_desc("Options");
po::variables_map vm;
int _tmain(int argc, TCHAR* argv[])
{
        int nRetCode = 0;

        // initialize MFC and print and error on failure
        if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
        {
                // TODO: change error code to suit your needs
                _tprintf(_T("Fatal Error: MFC initialization failed\n"));
                nRetCode = 1;
        }
        else
        {
//Setup our program options.
                options_desc.add_options()
                                ("help,h", "Produce help message")
                                ("cal_file,c", po::value< std::string >(), "Add use this
characterization file, overrides any other options(-I)" )
                                ("output_file,o", po::value< std::string >(), "File to write to." )
                                ("input_file,i", po::value< std::string >(), "Tab delimited file to
read from that characterizes frames to generate." )
                                ("ideal_perspective,I", "Use the default ideal perspective cubic
characterization." )
                                ("ideal_fisheye,F", "Use the default ideal fisheye cubic
characterization." )
                                ("num_video_streams,s", po::value<unsigned int>(), "Number of video
streams to create in the iPAN file." )
                                ("no_gps_stream", "Don't generate a GPS stream, but do put GPS data
in JPEG headers if input indicates it.")
                                ("no_att_stream", "Don't generate a attitude stream, but do put
attitude data in JPEG headers if input indicates it." )
// ("blocks,b", "Produce synchronization blocks")
                        ;

                po::store( parse_command_line(argc, argv, options_desc), vm );
                po::notify(vm);

                if( vm.count("help") )
                {
                        cout << options_desc << "\n";
                        return 1;
                }


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