下面的程序与pointer being freed was not allocated
中止:的boost :: program_options :: positional_options_description终止
#include <boost/program_options.hpp>
int main(int argc, char* argv[])
{
boost::program_options::positional_options_description positional;
return 0;
}
我编译和链接与升压1.46.1节目,这是我给自己建到/ usr/local,即在OS X 10.6.7。我找不到任何已安装的libboost_program_options,除了我(应该是)链接的。
任何想法是什么导致这次崩溃?
编辑:至于堆栈跟踪,程序
#include <boost/program_options.hpp>
#include <execinfo.h>
int main(int argc, char* argv[])
{
boost::program_options::positional_options_description positional;
void* callstack[128];
int i, frames = backtrace(callstack, 128);
char** strs = backtrace_symbols(callstack, frames);
for (i = 0; i < frames; ++i) {
printf("%s\n", strs[i]);
}
free(strs);
return 0;
}
构建为
g++ -Wp,-MMD,.make-debug/main.dd -Wall -g3 -I/usr/local/include -c main.cc -o .make-debug/main.o
g++ -o sandbox .make-debug/main.o -lboost_program_options -L/usr/local/lib
并运行作为./sandbox产生输出
0 sandbox 0x00000001000017bf main + 57
1 sandbox 0x0000000100001764 start + 52
2 ??? 0x0000000000000001 0x0 + 1
sandbox(50587) malloc: *** error for object 0x7fff70506500: pointer being freed was not al
located
*** set a breakpoint in malloc_error_break to debug
Command terminated
至于建设加速:
$ cd boost_1_46_1
$ ./bootstrap.sh --prefix=/usr/local
$ ./bjam toolset=darwin-4.2
这是我的〜/用户config.jam中:
using darwin : 4.0 : g++-4.0 ;
using darwin : 4.2 : g++-4.2 ;
using darwin : 4.5.1 : /Users/matan/usr/bin/g++ ;
有没有机会发布堆栈? – 2011-05-16 01:01:49
也尝试从Mac端口安装,而不是自己建设自己 – 2011-05-16 01:03:04
我只使用了1.44,但没有这个问题。 – 2011-05-16 01:26:36