我在一个项目上遇到了一个非常奇怪的错误我正在编写代码。 这是错误(使用valgrind)
==1930== Memcheck, a memory error detector
==1930== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==1930== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==1930== Command: ./main
==1930==
==1930== Warning: client switching stacks? SP change: 0xfff000280 --> 0xffc8e6590
==1930== to suppress, use: --max-stackframe=41000176 or greater
==1930== Invalid write of size 8
==1930== at 0x401288: main (main.c:70)
==1930== Address 0xffc8e6588 is on thread 1's stack
==1930== in frame #0, created by main (main.c:69)
==1930==
==1930==
==1930== Process terminating with default action of signal 11 (SIGSEGV)
==1930== Access not within mapped region at address 0xFFC8E6588
==1930== at 0x401288: main (main.c:70)
==1930== If you believe this happened as a result of a stack
==1930== overflow in your program's main thread (unlikely but
==1930== possible), you can try to increase the size of the
==1930== main thread stack using the --main-stacksize= flag.
==1930== The main thread stack size used in this run was 8388608.
==1930==
==1930== Process terminating with default action of signal 11 (SIGSEGV)
==1930== Access not within mapped region at address 0xFFC8E6581
==1930== at 0x4A236C0: _vgnU_freeres (vg_preloaded.c:58)
==1930== If you believe this happened as a result of a stack
==1930== overflow in your program's main thread (unlikely but
==1930== possible), you can try to increase the size of the
==1930== main thread stack using the --main-stacksize= flag.
==1930== The main thread stack size used in this run was 8388608.
==1930==
==1930== HEAP SUMMARY:
==1930== in use at exit: 37 bytes in 1 blocks
==1930== total heap usage: 1 allocs, 0 frees, 37 bytes allocated
==1930==
==1930== LEAK SUMMARY:
==1930== definitely lost: 0 bytes in 0 blocks
==1930== indirectly lost: 0 bytes in 0 blocks
==1930== possibly lost: 0 bytes in 0 blocks
==1930== still reachable: 37 bytes in 1 blocks
==1930== suppressed: 0 bytes in 0 blocks
==1930== Reachable blocks (those to which a pointer was found) are not shown.
==1930== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==1930==
==1930== For counts of detected and suppressed errors, rerun with: -v
==1930== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Erreur de segmentation (segfault basically)
我会在我的同事计算机(实际上是MACOSX)上添加它,它完全正常。
这是我们的(awfull)main,第70行是我们.c文件中main的第一行:(还是WIP请原谅我在这里发生的所有狗屎^^)
int main(int argc, char* argv[]) {
printf("derp\n");
int i = 0;
char lines[MAXLINES][BUFSIZ];
char* path[MAXLINES];
printf("derp\n");
FILE *fp = fopen("./Images/125/DBtexte.txt", "r");
if (fp == 0) {
fprintf(stderr, "failed to open DBtexte\n");
exit(1);
}
printf("derp\n");
while (i < MAXLINES && fgets(lines[i], sizeof(lines[0]), fp)) {
lines[i][strlen(lines[i])-1] = '\0';
i = i + 1;
}
i = 0;
printf("derp\n");
while(strcmp(lines[i],"\0"))
i++;
char *folder = "./Images/125/";
for (size_t j = 0; j<(size_t)i; j++) {
char *temp = lines[j];
char *temp2 = (char *) malloc(1 + strlen(folder)+ strlen(temp));
strcat(temp2,folder);
strcat(temp2,temp);
path[j] = temp2;
//printf("%s\n",path[j]);
}
fclose(fp);
int *visage = faces(i-1,i);
printf("\nTHE FACE IS A LIE\n");
/*if (argc < 2)
errx(2, "Usage:\n%s <path>", argv[0]);
SDL_Surface* image = load_image(argv[1]);
display_image(image);
ToGray(image);
display_image(image);
Binarize(image);
display_image(image); */
printf("ONSTART\n");
strongClassifier* yolo;
yolo = adaboost(path, visage, 124, 1, 20);
//int len;
//haarRecord* haarOutput;
//haarOutput = processImage(image, &len);
//display_haar(haarOutput, len);
//SDL_SaveBMP(image, "./ToGray.bmp");
return 0;
}
真的期待你的帮助:)