у меня такой код
void find_groupings ()
int *bandwidths;
int *execution_time;
bandwidths = (int *)malloc(sizeof(int)*node_count); // node_count is glbl
execution_time = (int *)malloc(sizeof(int)*node_count);
//other mallocs, other code etc
while (condition) {
// lot of code
find_bandwidths(bandwidths);
find_execution_time(execution_time);
//lot of code
}
free(bandwidths);
free(execution_time);
}
ошибки сегментации кода в строке "free(execution_time);"
Thread 1 "vx_tutorial_exe" received signal SIGSEGV, Segmentation fault.
0xf7dd0cd9 in _int_free (av=0xf7f15780 <main_arena>, p=<optimized out>, have_lock=0) at malloc.c:4005
4005 malloc.c: No such file or directory.
Я могу гарантировать, что «execution_time» не выходит за пределы внутри find_execution_time(). Я считаю, что освобождаю каждый malloc, который я делаю в коде.
Также обнаружено, что значение указателя для execute_time одинаково непосредственно перед сбоем в free() с использованием gdb.
пробовал valgrind, но это не помогает, так как программа segfaults
В чем здесь может быть проблема?
other code
. Или, может быть, ваши mallocs терпят неудачу. Хотя бы проверить на ноль - person pm100   schedule 20.09.2018