Restart CI for New Technology and UBSAN hunting

Continuous Integration (via runit and runitd) is now re-enabled on win7
and win10. The `make test` command, which runs the tests on all systems
is now the fastest and most stable it's been since the project started.

UBSAN is now enabled in MODE=dbg in addition to ASAN. Many instances of
undefined behavior have been removed. Mostly things like passing a NULL
argument to memcpy(), which works fine with Cosmopolitan Libc, but that
doesn't prevents the compiler from being unhappy. There was an issue w/
GNU make where static analysis claims a sprintf() call can overflow. We
also now have nicer looking crash reports on Windows since uname should
now be supported and msys64 addr2line works reliably.
This commit is contained in:
Justine Tunney 2022-03-21 03:46:16 -07:00
parent d5ff2c3fb9
commit 5e8ae2d5bc
80 changed files with 506 additions and 249 deletions

View file

@ -3105,7 +3105,7 @@ static void OnlyRunOnFirstCpu(void) {
}
int main(int argc, char *argv[]) {
if (!NoDebug()) showcrashreports();
if (!NoDebug()) ShowCrashReports();
pty = NewPty();
pty->conf |= kPtyNocanon;
m = NewMachine();

View file

@ -727,7 +727,7 @@ void GetOpts(int argc, char *argv[]) {
int main(int argc, char *argv[]) {
int i, rc;
showcrashreports();
ShowCrashReports();
GetOpts(argc, argv);
xsigaction(SIGFPE, OnDivideError, 0, 0, 0);
if (optind == argc) {

View file

@ -101,7 +101,7 @@ FLAGS\n\
-C SECS set cpu limit [default 16]\n\
-L SECS set lat limit [default 90]\n\
-M BYTES set mem limit [default 512m]\n\
-F BYTES set fsz limit [default 100m]\n\
-F BYTES set fsz limit [default 256m]\n\
-O BYTES set out limit [default 1m]\n\
-s decrement verbosity [default 4]\n\
-v increments verbosity [default 4]\n\
@ -725,14 +725,15 @@ int main(int argc, char *argv[]) {
int ws, opt, exitcode;
char *s, *p, *q, **envp;
mode = firstnonnull(getenv("MODE"), MODE);
/*
* parse prefix arguments
*/
mode = MODE;
verbose = 4;
timeout = 90; /* secs */
cpuquota = 16; /* secs */
fszquota = 100 * 1000 * 1000; /* bytes */
fszquota = 256 * 1000 * 1000; /* bytes */
memquota = 512 * 1024 * 1024; /* bytes */
if ((s = getenv("V"))) verbose = atoi(s);
while ((opt = getopt(argc, argv, "hnvstC:M:F:A:T:V:O:L:")) != -1) {
@ -785,6 +786,16 @@ int main(int argc, char *argv[]) {
exit(1);
}
/*
* extend limits for slow UBSAN in particular
*/
if (!strcmp(mode, "dbg") || !strcmp(mode, "ubsan")) {
cpuquota *= 2;
fszquota *= 2;
memquota *= 2;
timeout *= 2;
}
cmd = argv[optind];
if (!strchr(cmd, '/')) {
if (!(cmd = commandv(cmd, ccpath))) exit(127);
@ -957,11 +968,13 @@ int main(int argc, char *argv[]) {
}
if (wantasan) {
AddArg("-fsanitize=address");
AddArg("-D__FSANITIZE_ADDRESS__");
/* compiler adds this by default */
/* AddArg("-D__SANITIZE_ADDRESS__"); */
}
if (wantubsan) {
AddArg("-fsanitize=undefined");
AddArg("-fno-data-sections");
AddArg("-D__SANITIZE_UNDEFINED__");
}
if (no_sanitize_null) {
AddArg("-fno-sanitize=null");

View file

@ -275,7 +275,7 @@ void Disassemble(void) {
}
int main(int argc, char *argv[]) {
showcrashreports();
ShowCrashReports();
int fd;
void *map;
struct stat st;

View file

@ -141,7 +141,9 @@ static void FlushTables(struct ElfWriter *elf) {
symtab = AppendSection(elf, ".symtab", SHT_SYMTAB, 0);
for (i = 0; i < ARRAYLEN(elf->syms); ++i) {
size = elf->syms[i]->i * sizeof(Elf64_Sym);
memcpy(elfwriter_reserve(elf, size), elf->syms[i]->p, size);
if (size) {
memcpy(elfwriter_reserve(elf, size), elf->syms[i]->p, size);
}
elfwriter_commit(elf, size);
}
FinishSection(elf);

View file

@ -63,7 +63,7 @@ int main(int argc, char *argv[]) {
int opt;
FILE *fin, *fout;
showcrashreports();
ShowCrashReports();
while ((opt = getopt(argc, argv, "ho:s:z:")) != -1) {
switch (opt) {

View file

@ -87,7 +87,7 @@
* - 1 byte exit status
*/
#define DEATH_CLOCK_SECONDS 16
#define DEATH_CLOCK_SECONDS 32
#define kLogFile "o/runitd.log"
#define kLogMaxBytes (2 * 1000 * 1000)