Make detached threads work better

This change adds a double linked list of threads, so that pthread_exit()
will know when it should call exit() from an orphaned child. This change
also improves ftrace and strace logging.
This commit is contained in:
Justine Tunney 2022-11-09 03:58:57 -08:00
parent b74d8c1acd
commit cee6871710
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
37 changed files with 638 additions and 314 deletions

View file

@ -16,6 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/calls/blockcancel.internal.h"
#include "libc/calls/calls.h"
#include "libc/calls/struct/rusage.internal.h"
#include "libc/calls/syscall-sysv.internal.h"
@ -62,10 +63,12 @@ static int PrintBacktraceUsingAddr2line(int fd, const struct StackFrame *bp) {
}
if (!PLEDGED(STDIO) || !PLEDGED(EXEC) || !PLEDGED(EXEC)) {
ShowHint("won't print addr2line backtrace because pledge");
return -1;
}
if (!(debugbin = FindDebugBinary())) {
ShowHint("won't print addr2line backtrace because no debug binary");
return -1;
}
@ -171,11 +174,14 @@ static int PrintBacktrace(int fd, const struct StackFrame *bp) {
return 0;
}
}
#else
ShowHint("won't print addr2line backtrace because no dwarf");
#endif
return PrintBacktraceUsingSymbols(fd, bp, GetSymbolTable());
}
void ShowBacktrace(int fd, const struct StackFrame *bp) {
BLOCK_CANCELLATIONS;
#ifdef __FNO_OMIT_FRAME_POINTER__
/* asan runtime depends on this function */
ftrace_enabled(-1);
@ -189,4 +195,5 @@ void ShowBacktrace(int fd, const struct StackFrame *bp) {
"\t-D__FNO_OMIT_FRAME_POINTER__\n"
"\t-fno-omit-frame-pointer\n");
#endif
ALLOW_CANCELLATIONS;
}