On 08/16/17 09:50 AM, hai huang wrote: > Actually, this problem can be reproduced with an even simpler program: > > #include <stdio.h> > #include <unistd.h> > #include <sys/time.h> > > int main() { > struct timeval tv; > gettimeofday(&tv, NULL); > } > > > If I compile this with `gcc -O2 -o test_O2 test.c` and run > `libunwind/tests/test-ptrace -s -v ./test_O2` to trace it, I will get the > same behavior as above with `main+0x1e` showing up twice in the backtrace. > However, the weird thing is if I replace gettimeofday() call with a > sleep(1) call, even compiling with the `-O2` flag, backtrace looks fine. > Maybe there's a strange interaction between libunwind and gettimeofday > syscall?
So my first guess would be that it's because you are trying to ptrace and backtrace syscalls, but gettimeofday is no longer a syscall on modern linux systems, it's a vdso call: https://github.com/lattera/glibc/blob/master/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c#L34 And this is why sleep works fine - it's stil a normal syscall _______________________________________________ Libunwind-devel mailing list Libunwind-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/libunwind-devel