I've had trouble before with this same program because it makes lots of memory allocations. I got rid of most problems but I'm still having trouble with one particular problem. When I ran my program in Eclipse it compiles well but it crashes with this message
*** glibc detected *** /home/user/workspace/TTPrueba/Debug/TTPrueba: free(): invalid pointer: 0xb6bc0588 ***
When I ran it with Valgrind it tells me this
==31580== Process terminating with default action of signal 11 (SIGSEGV)
==31580== Access not within mapped region at address 0x0
==31580== at 0x804BEA3: termino (Menu.c:899)
==31580== by 0x804BE05: computar_transformadas (Menu.c:840)
So the problem is that it is trying to free an invalid memory address but then I go step by step in debug mode and the program never crashes!!!! :(
Any idea why such a thing could happen? How come it works while debugging but not while running? This is pretty strange behavior.
for(phi=0;phi<360;phi++){
for(j=0;j<par.param1[phi][0];j++){
for(o=0;o<(par.prueba[phi][j][1]-par.prueba[phi][j][0]);o++){//AQUI 849
free(par.pixels[phi][j][o]);//HERE IS LINE 899 WHERE IT ALWAYS CRASHES
if(o==(par.prueba[phi][j][1]-par.prueba[phi][j][0]-1))
free(par.pixels[phi][j]);
}
free(par.prueba[phi][j]);
}
Thanks for the help!