下面的程序與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