malloc: 对象 0x1029249b0 的 *** 错误:未分配正在释放的指针

malloc: *** error for object 0x1029249b0: pointer being freed was not allocated

本文关键字:释放 指针 分配 错误 对象 0x1029249b0 malloc      更新时间:2023-10-16

我正在尝试在带有xcode 3.2.6的mac OS X 10.6.8上编译一个包含-std=c++0x的程序。我用自制软件将我的 g++ 编译器升级到 g++-4.7。在我的制作文件中,我将行从:

CXX          = g++
CXXFLAGS     = -std=c++0x
LD           = g++
LDFLAGS      = -L.

自:

CXX          = g++-4.7
CXXFLAGS     = -std=c++0x
LD           = g++-4.7
LDFLAGS      = -L.

但是,此行不起作用:

$(CC) -c -Icore/include/ -Ianalysis/include -Ieventbuilders/include -Isimdut/include -Istyle/include $(CXXFLAGS) $< -o $@

所以我把它改成:

$(CXX) -c -Icore/include/ -Ianalysis/include -Ieventbuilders/include -Isimdut/include -Istyle/include $(CXXFLAGS) $< -o $@

现在一切都可以编译,但是当我运行文件时,出现以下错误:

tbmon(25203) malloc: *** error for object 0x1029249b0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap

有人可以告诉我我做错了什么吗?提前谢谢你!

程序中有一个错误,它在指针上调用free(),而指针不是通过malloc()获得的。或代码中触发此行为的其他一些与内存相关的错误。

制作您提供的文件与此问题无关。您必须修复程序代码。

只是将编译器从gcc更改为g++不应该导致free(3)失败。您能否发布一个演示该问题的最小示例?