Program options (1.43.0) problem on Mac OS 10.6: pointer being freed not allocated
I'm using boost 1.43.0. I have enclose a program which uses
boost::program_options on a Mac OS 10.6 and when I run it, I get
errors. I have compiled boost with g++ version 4.4.1 and version 4.5.0
and I get the same errors. I have tried the version of boost (1.42.0)
that comes from macports as well as downloaded version that I have build.
clo(87082) malloc: *** error for object 0xa0136db0: pointer being freed
was not allocated.
The program is given below. I have run the same program with boost
1.43.0 under linux and I don't get any errors. It is also completely
clean of any errors when run through valgrind. The program is an
example showing problem I'm having. It has been extracted from a larger
program. Am I correctly using the library
or is there a problem with boost (and only on a Mac?)
Thanks for any help.
-----------------------------------------------------------------------------------------------------------------------
#include<iostream>
#include<string>
#include
Robert McLay wrote:
I'm using boost 1.43.0. I have enclose a program which uses boost::program_options on a Mac OS 10.6 and when I run it, I get errors. I have compiled boost with g++ version 4.4.1 and version 4.5.0 and I get the same errors. I have tried the version of boost (1.42.0) that comes from macports as well as downloaded version that I have build.
clo(87082) malloc: *** error for object 0xa0136db0: pointer being freed was not allocated.
The program is given below. I have run the same program with boost 1.43.0 under linux and I don't get any errors. It is also completely clean of any errors when run through valgrind. The program is an example showing problem I'm having. It has been extracted from a larger program. Am I correctly using the library or is there a problem with boost (and only on a Mac?)
Could you catch a backtrace at the point where error happens? - Volodya
I'm assuming your code works correctly on the apple-supplied compiler?
The problem is a bug in Mac OS X Snow Leopard (10.6), where the system binaries are compiled with _GLIBCXX_FULLY_DYNAMIC_STRING, but the headers do not define that term. This is not a problem with your code or program options. A smaller example which produces the same problem:
#include
I'm using boost 1.43.0. I have enclose a program which uses boost::program_options on a Mac OS 10.6 and when I run it, I get errors. I have compiled boost with g++ version 4.4.1 and version 4.5.0 and I get the same errors. I have tried the version of boost (1.42.0) that comes from macports as well as downloaded version that I have build.
clo(87082) malloc: *** error for object 0xa0136db0: pointer being freed was not allocated.
The program is given below. I have run the same program with boost 1.43.0 under linux and I don't get any errors. It is also completely clean of any errors when run through valgrind. The program is an example showing problem I'm having. It has been extracted from a larger program. Am I correctly using the library or is there a problem with boost (and only on a Mac?)
Thanks for any help. -----------------------------------------------------------------------------------------------------------------------
#include<iostream> #include<string> #include
class CmdLineOptions { public: CmdLineOptions(int argc, char* argv[]); bool is_good() {return m_isGood;}
public: bool negative; int clustSize; float rebuildRatio; std::string input_file;
private: bool m_isGood; };
namespace po = boost::program_options; CmdLineOptions::CmdLineOptions(int argc, char* argv[]) : m_isGood(true) { po::options_description visible("Options"); visible.add_options() ("version,v", "print version string") ("help,h", "produce help message") ("question,?", "produce help message") ("clust_size,s", po::value<int>()->default_value(30), "cluster size") ("rebuild_ratio,r", po::value<float>()->default_value(0.5), "Rebuild ratio") ("negative,n", "Allow negative distances") ;
// Hidden options, will be allowed both on command line po::options_description hidden("Hidden options"); hidden.add_options() ("input-file", po::valuestd::string(), "input file") ;
po::options_description cmdline_options; cmdline_options.add(visible).add(hidden);
po::positional_options_description p; p.add("input-file", -1);
po::variables_map vm; store(po::command_line_parser(argc, argv). options(cmdline_options).positional(p).run(), vm);
if (vm.count("input-file") == 0 || vm.count("help") || vm.count("question")) { std::cerr<< "\nUsage:\n" << " "<< argv[0]<< " [options] input_file\n\n" << visible<< std::endl; m_isGood = false; return; }
clustSize = vm["clust_size"].as<int>(); input_file = vm["input-file"].asstd::string(); rebuildRatio = vm["rebuild_ratio"].as<float>(); negative = vm.count("negative")> 0; }
int main(int argc, char * argv[]) {
// Parse Command line options CmdLineOptions cmd(argc, argv); if (! cmd.is_good()) return 1;
std::cout<< "clustSize: "<< cmd.clustSize<< " rebuild factor: "<< cmd.rebuildRatio<< "\n";
}
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Christopher Jefferson
-
Robert McLay
-
Vladimir Prus