mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-22 12:28:31 +00:00
Overhaul process spawning
This commit is contained in:
parent
99dc1281f5
commit
26e254fb4d
96 changed files with 1848 additions and 1541 deletions
|
@ -40,6 +40,7 @@
|
|||
#include "net/http/escape.h"
|
||||
#ifdef __x86_64__
|
||||
|
||||
#if 0
|
||||
__static_yoink("backtrace.com");
|
||||
__static_yoink("backtrace.com.dbg");
|
||||
|
||||
|
@ -115,20 +116,12 @@ TEST(ShowCrashReports, testMemoryLeakCrash) {
|
|||
}
|
||||
close(fds[0]);
|
||||
ASSERT_NE(-1, wait(&ws));
|
||||
EXPECT_TRUE(WIFEXITED(ws));
|
||||
EXPECT_EQ(78, WEXITSTATUS(ws));
|
||||
if (!strstr(output, "UNFREED MEMORY")) {
|
||||
fprintf(stderr, "ERROR: crash report didn't report leak\n%s\n",
|
||||
_gc(IndentLines(output, -1, 0, 4)));
|
||||
__die();
|
||||
}
|
||||
// tinyprint(2, _gc(IndentLines(output, -1, 0, 4)), "\n", NULL);
|
||||
EXPECT_EQ(78 << 8, ws);
|
||||
ASSERT_TRUE(!!strstr(output, "UNFREED MEMORY"));
|
||||
if (IsAsan()) {
|
||||
if (!OutputHasSymbol(output, "strdup") ||
|
||||
!OutputHasSymbol(output, "MemoryLeakCrash")) {
|
||||
fprintf(stderr, "ERROR: crash report didn't backtrace allocation\n%s\n",
|
||||
_gc(IndentLines(output, -1, 0, 4)));
|
||||
__die();
|
||||
}
|
||||
ASSERT_TRUE(OutputHasSymbol(output, "strdup") &&
|
||||
OutputHasSymbol(output, "MemoryLeakCrash"));
|
||||
}
|
||||
free(output);
|
||||
}
|
||||
|
@ -215,15 +208,16 @@ TEST(ShowCrashReports, testDivideByZero) {
|
|||
}
|
||||
close(fds[0]);
|
||||
ASSERT_NE(-1, wait(&ws));
|
||||
EXPECT_TRUE(WIFEXITED(ws));
|
||||
assert(128 + SIGFPE == WEXITSTATUS(ws) || 77 == WEXITSTATUS(ws));
|
||||
// tinyprint(2, _gc(IndentLines(output, -1, 0, 4)), "\n", NULL);
|
||||
if (IsModeDbg()) {
|
||||
EXPECT_EQ(77 << 8, ws);
|
||||
} else {
|
||||
EXPECT_TRUE(WIFSIGNALED(ws));
|
||||
EXPECT_EQ(SIGFPE, WTERMSIG(ws));
|
||||
}
|
||||
/* NULL is stopgap until we can copy symbol tables into binary */
|
||||
#ifdef __FNO_OMIT_FRAME_POINTER__
|
||||
if (!OutputHasSymbol(output, "FpuCrash")) {
|
||||
fprintf(stderr, "ERROR: crash report didn't have backtrace\n%s\n",
|
||||
_gc(IndentLines(output, -1, 0, 4)));
|
||||
__die();
|
||||
}
|
||||
ASSERT_TRUE(OutputHasSymbol(output, "FpuCrash"));
|
||||
#endif
|
||||
if (strstr(output, "divrem overflow")) {
|
||||
// UBSAN handled it
|
||||
|
@ -339,21 +333,18 @@ TEST(ShowCrashReports, testBssOverrunCrash) {
|
|||
}
|
||||
close(fds[0]);
|
||||
ASSERT_NE(-1, wait(&ws));
|
||||
EXPECT_TRUE(WIFEXITED(ws));
|
||||
EXPECT_EQ(77, WEXITSTATUS(ws));
|
||||
// tinyprint(2, _gc(IndentLines(output, -1, 0, 4)), "\n", NULL);
|
||||
EXPECT_EQ(77 << 8, ws);
|
||||
/* NULL is stopgap until we can copy symbol tablces into binary */
|
||||
#ifdef __FNO_OMIT_FRAME_POINTER__
|
||||
if (!OutputHasSymbol(output, "BssOverrunCrash")) {
|
||||
fprintf(stderr, "ERROR: crash report didn't have backtrace\n%s\n",
|
||||
_gc(IndentLines(output, -1, 0, 4)));
|
||||
__die();
|
||||
}
|
||||
ASSERT_TRUE(OutputHasSymbol(output, "BssOverrunCrash"));
|
||||
#endif
|
||||
if (!strstr(output, "'int' index 10 into 'char [10]' out of bounds") &&
|
||||
(!strstr(output, "☺☻♥♦♣♠•◘○") || !strstr(output, "global redzone"))) {
|
||||
fprintf(stderr, "ERROR: crash report didn't have memory diagram\n%s\n",
|
||||
_gc(IndentLines(output, -1, 0, 4)));
|
||||
__die();
|
||||
if (IsAsan()) {
|
||||
ASSERT_TRUE(
|
||||
!!strstr(output, "'int' index 10 into 'char [10]' out of bounds"));
|
||||
} else {
|
||||
ASSERT_TRUE(!!strstr(output, "☺☻♥♦♣♠•◘○"));
|
||||
ASSERT_TRUE(!!strstr(output, "global redzone"));
|
||||
}
|
||||
free(output);
|
||||
}
|
||||
|
@ -417,30 +408,15 @@ TEST(ShowCrashReports, testNpeCrash) {
|
|||
}
|
||||
close(fds[0]);
|
||||
ASSERT_NE(-1, wait(&ws));
|
||||
EXPECT_TRUE(WIFEXITED(ws));
|
||||
EXPECT_EQ(77, WEXITSTATUS(ws));
|
||||
// tinyprint(2, _gc(IndentLines(output, -1, 0, 4)), "\n", NULL);
|
||||
EXPECT_EQ(77 << 8, ws);
|
||||
/* NULL is stopgap until we can copy symbol tables into binary */
|
||||
if (!strstr(output, "null pointer")) {
|
||||
fprintf(stderr, "ERROR: crash report didn't diagnose the problem\n%s\n",
|
||||
_gc(IndentLines(output, -1, 0, 4)));
|
||||
__die();
|
||||
}
|
||||
ASSERT_TRUE(!!strstr(output, "null pointer"));
|
||||
#ifdef __FNO_OMIT_FRAME_POINTER__
|
||||
if (!OutputHasSymbol(output, "NpeCrash")) {
|
||||
fprintf(stderr, "ERROR: crash report didn't have backtrace\n%s\n",
|
||||
_gc(IndentLines(output, -1, 0, 4)));
|
||||
__die();
|
||||
}
|
||||
ASSERT_TRUE(OutputHasSymbol(output, "NpeCrash"));
|
||||
#endif
|
||||
if (strstr(output, "null pointer access")) {
|
||||
// ubsan nailed it
|
||||
} else {
|
||||
// asan nailed it
|
||||
if (!strstr(output, "∅∅∅∅")) {
|
||||
fprintf(stderr, "ERROR: crash report didn't have shadow diagram\n%s\n",
|
||||
_gc(IndentLines(output, -1, 0, 4)));
|
||||
__die();
|
||||
}
|
||||
if (!strstr(output, "null pointer access")) { // ubsan
|
||||
ASSERT_TRUE(!!strstr(output, "∅∅∅∅")); // asan
|
||||
}
|
||||
free(output);
|
||||
}
|
||||
|
@ -476,21 +452,15 @@ TEST(ShowCrashReports, testDataOverrunCrash) {
|
|||
}
|
||||
close(fds[0]);
|
||||
ASSERT_NE(-1, wait(&ws));
|
||||
EXPECT_TRUE(WIFEXITED(ws));
|
||||
EXPECT_EQ(77, WEXITSTATUS(ws));
|
||||
// tinyprint(2, _gc(IndentLines(output, -1, 0, 4)), "\n", NULL);
|
||||
EXPECT_EQ(77 << 8, ws);
|
||||
/* NULL is stopgap until we can copy symbol tablces into binary */
|
||||
#ifdef __FNO_OMIT_FRAME_POINTER__
|
||||
if (!OutputHasSymbol(output, "DataOverrunCrash")) {
|
||||
fprintf(stderr, "ERROR: crash report didn't have backtrace\n%s\n",
|
||||
_gc(IndentLines(output, -1, 0, 4)));
|
||||
__die();
|
||||
}
|
||||
ASSERT_TRUE(OutputHasSymbol(output, "DataOverrunCrash"));
|
||||
#endif
|
||||
if (!strstr(output, "'int' index 10 into 'char [10]' out of bounds") &&
|
||||
(!strstr(output, "☺☻♥♦♣♠•◘○") || !strstr(output, "global redzone"))) {
|
||||
fprintf(stderr, "ERROR: crash report didn't have memory diagram\n%s\n",
|
||||
_gc(IndentLines(output, -1, 0, 4)));
|
||||
__die();
|
||||
if (!strstr(output, "'int' index 10 into 'char [10]' out")) { // ubsan
|
||||
ASSERT_TRUE(!!strstr(output, "☺☻♥♦♣♠•◘○")); // asan
|
||||
ASSERT_TRUE(!!strstr(output, "global redzone")); // asan
|
||||
}
|
||||
free(output);
|
||||
}
|
||||
|
@ -530,9 +500,13 @@ TEST(ShowCrashReports, testNpeCrashAfterFinalize) {
|
|||
}
|
||||
close(fds[0]);
|
||||
ASSERT_NE(-1, wait(&ws));
|
||||
EXPECT_TRUE(WIFEXITED(ws));
|
||||
EXPECT_EQ(0, WTERMSIG(ws));
|
||||
EXPECT_EQ(IsAsan() ? 77 : 128 + SIGSEGV, WEXITSTATUS(ws));
|
||||
// tinyprint(2, _gc(IndentLines(output, -1, 0, 4)), "\n", NULL);
|
||||
if (IsModeDbg()) {
|
||||
EXPECT_EQ(77 << 8, ws);
|
||||
} else {
|
||||
EXPECT_TRUE(WIFSIGNALED(ws));
|
||||
EXPECT_EQ(SIGSEGV, WTERMSIG(ws));
|
||||
}
|
||||
/* NULL is stopgap until we can copy symbol tables into binary */
|
||||
if (!strstr(output, IsAsan() ? "null pointer" : "Uncaught SIGSEGV (SEGV_")) {
|
||||
fprintf(stderr, "ERROR: crash report didn't diagnose the problem\n%s\n",
|
||||
|
@ -548,5 +522,6 @@ TEST(ShowCrashReports, testNpeCrashAfterFinalize) {
|
|||
#endif
|
||||
free(output);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue