当我运行代码时
char* dirPath = (char*) malloc(pathSize); // pathSize is 512 and its pre defined
readlink("/proc/self/exe",dirPath,pathSize); //segfault here
它段错误。我已经尝试增加 pathSize 的值或将 pathSize 值大一传递到 readlink。我还将 /proc/self/exe 放在单独的变量中并传递它也不起作用。通过 gdb 运行程序说。
Program received signal SIGSEGV, Segmentation fault.
__memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:384
384 ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: No such file or directory.
代码工作了很长时间,但最近才破解