debugging - c++: Unhandled exception at 0x57B4B2CE (msvcr120d.dll) in Program.exe: 0xC0000005: Access violation reading location 0xCDCDCDC8 -


i getting error

unhandled exception @ 0x57b4b2ce (msvcr120d.dll) in program.exe: 0xc0000005: access violation reading location 0xcdcdcdc8 

and happens in part of code:

void print_function(char * output_file) {     f = 0;     f = fopen(output_file,"w");      (int = 0 ; < count_total ; i++)     {         (int j = 0 ; j < sizes[i] ; j++)         {             (int k = 0 ; k < rules[i][j]->sizes_elements ; k++)                 if (k < rules[i][j]->sizes_elements - 1) fprintf(f,"%i ", elements[rules[i][j]->elements[k]]);                 else fprintf(f,"%i", elements[rules[i][j]->elements[k]]);              fprintf(f,":%.3f:%i\n", rules[i][j]->measure_value,rules[i][j]->index);              free(rules[i][j]->elements); rules[i][j]->elements = 0;             free(rules[i][j]); rules[i][j] = 0;         }          free(rules[i]); rules[i] = 0;     }      fclose(f); f = 0;      free(rules); rules = 0;     free(size_rules); size_rules = 0;     free(elements); elements = 0; } 

the exception launches in part of code specifically

free(rules[i]); rules[i] = 0;     

after first iteration of outer loop, previous free doing not noticing , not im expecting be?

any appreciated.

visual studio uses several fake addresses indicators of state of memory:

  • 0x00000000 : nullptr or null
  • 0xfeeefeee : delete has been called
  • 0xcdcdcdcd : memory created not initialized.

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 -