program_options application crashes when printing options descriptions

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; }

Matt Schuckmann wrote:
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).
That specific issue is fixed in CVS HEAD (and RC_1_34_0) quite some time ago. Can you try that version and let me know if the problem is gone? - Volodya

Vladimir Prus wrote:
Matt Schuckmann wrote:
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).
That specific issue is fixed in CVS HEAD (and RC_1_34_0) quite some time ago. Can you try that version and let me know if the problem is gone?
- Volodya
I can try, of course if it does it doesn't really fix the problem until 1.34 is release and I can convince my group to update boost again. Matt S.

Vladimir Prus wrote:
Matt Schuckmann wrote:
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).
That specific issue is fixed in CVS HEAD (and RC_1_34_0) quite some time ago. Can you try that version and let me know if the problem is gone?
- Volodya
I got boost rc 1.34 built it and tested and it does now work with the code I provided above. I can't just upgrade to rc 1.34, I think I'd be shot by my co workers and boss. Is there a patch or fix I can apply to our 1.33.1 build? Thanks Matt S. PS I did run into another problem with an other command line program, the description for one of the parameters has multiple lines and some of those lines have 2 or more tabs to produce output like this -C [--compress] arg Compress input file to output file. Compression Types are 0 - No Compression 1 - little bit 2 - lots The option description looks like this in my code ("compress,C", po::value< int >(), "Compress input file to output file.\n" "\tCompression Types are\n." "\t\t0 - No compression\n" "\t\t1 - little bit\n" "\t\t2 - lots\n" ) The multiple tabs on the argument types lines are producing an exception with the description "Only one tab per paragraph is allowed" What is the reason for not allowing multiple tabs, and if multiple tabs truly can't be used how should one produce output with multiple levels of indentation? Thanks Matt S.
participants (2)
-
Matt Schuckmann
-
Vladimir Prus