signal 6 - SIGABRT
free 多次
- char *p = malloc(100);
- free(p);
- free(p);
fclose 多次
- // fclose 内部调用 free
- FILE *fp = fopen("test.txt", "wb+");
- printf("%p\n", fp);
- fclose(fp);
- printf("%p\n", fp);
- fclose(fp);
- printf("%p\n", fp);
查看栈回溯,跟 free 多次一样,查看 glibc/libio
signal 11 - SIGSEGV
引用空指针成员
- struct Hello *p = NULL;
- printf("%d\n", p->a);
fclose 空指针
- // fclose 内部引用 FILE 成员
- FILE *fp = NULL;
- fclose(fp);
跟引用空指针成员一致。