strange behavior by delete function (mixed C and C++) -


i'm debugging program found data being changed shouldn't. traced program using gdb , found target data changed in delete function of other data!

at first figured there memory overlapping between both areas, checked start , end addresses of both areas , not overlap! leaves delete line!

this function happens, data shouldn't change freemap , data being freed synthops:

void basicblock::free() {   cout << "freemap 2 : " << this->mfnlo_loc.chunk->freemap[2] << "\n";   cout << "freemap 59 : " << this->mfnlo_loc.chunk->freemap[59] << "\n";   cout << "freemap : " << &(this->mfnlo_loc.chunk->freemap) << "\t" << sizeof(this->mfnlo_loc.chunk->freemap)+&(this->mfnlo_loc.chunk->freemap) << "\n";   cout << "synthops : " << synthops << "\t" << synthops+sizeof(uopimpl_func_t)*count << "\n";   if (synthops)    {       delete[] synthops;    }   cout << "freemap 2 : " << (this->mfnlo_loc.chunk->freemap[2]) << "\n";   cout << "freemap 59 : "  << this->mfnlo_loc.chunk->freemap[59] << "\n";   synthops = null;   ::free(this); } 

the output this:

freemap 2 : 1 freemap 59 : 1 freemap : 0x3319a50 0x3319a90 synthops : 0x3319d50    0x331acd0 freemap 2 : 0 freemap 59 : 0 

it shown freemap changes after delete line, shows both don't overlap in memory.

synthops allocated in function this:

bb.synthops = new uopimpl_func_t[bb.count]; 

why happen? code mix of c , c++ means there mix of new , malloc (but used consistently, no delete malloc example). reason this? or else?

my psychic debugging skills tell me didn't follow rule of 3 basicblock, omitted copy constructor. (shallow) copied object (and synthops member), , resulted in double deletion @ point bets off.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -