To get reliable stack traces GDB has to have access to either frame pointer (-fno-omit-frame-pointer compiler flag) or to unwind tables (-funwind-tables). In the absence of either of these, GDB has to guess where stack frame boundaries are. In this case GDB guesses wrong.
The recommended way to get reliable stack traces is to use -funwind-tables, which does not have performance penalty (like -fno-omit-frame-pointer), and only increases disk footprint of binaries by several percent.
How was "sleep" and system glibc compiled?
To get reliable stack traces GDB has to have access to either frame pointer (-fno-omit- frame-pointer compiler flag) or to unwind tables (-funwind-tables). In the absence of either of these, GDB has to guess where stack frame boundaries are. In this case GDB guesses wrong.
The recommended way to get reliable stack traces is to use -funwind-tables, which does not have performance penalty (like -fno-omit- frame-pointer) , and only increases disk footprint of binaries by several percent.