简体   繁体   中英

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

I'm trying to compile a program which contains -std=c++0x on a mac OS X 10.6.8 with xcode 3.2.6. I upgraded my g++ compiler to g++-4.7 with homebrew. In my makefile I changed the lines from:

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

to:

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

however, this line wasn't working:

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

so I changed it to:

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

everything now compiles, but when I run my file I get the following error:

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

Could someone please advise me what I've done wrong? Thank you in advance!

You've got a bug in the program where it calls free() on a pointer that wasn't obtained with malloc() . Or some other memory-related bug in the code that triggers this behavior.

Make files you have provided are not related to this problem. You have to fix the program code.

Just changing the compiler from, presumably, gcc to g++ shouldn't cause free(3) to fail. Could you please post a minimal example demonstrating the issue?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM