From 3d7b82936ec5f2fe55201c53ed805b4461d3d28b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 3 May 2019 16:02:32 -0700 Subject: [PATCH 1/4] fixes reference counts in _pier_work_boot() --- pkg/urbit/vere/pier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index 730e47f095..9a5a3ad007 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -508,7 +508,7 @@ _pier_work_boot(u3_pier* pir_u, c3_o sav_o) u3_noun len = u3i_chubs(1, &pir_u->lif_d); if ( c3y == sav_o ) { - _pier_db_write_header(pir_u, who, u3k(pir_u->fak_o), len); + _pier_db_write_header(pir_u, u3k(who), pir_u->fak_o, u3k(len)); } u3_noun msg = u3nq(c3__boot, who, pir_u->fak_o, len); From e171596d985c1acabf405303c7553f1268f29f9f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 3 May 2019 16:10:26 -0700 Subject: [PATCH 2/4] adds (disabled) code to print and save comet "keyfile" --- pkg/urbit/vere/dawn.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pkg/urbit/vere/dawn.c b/pkg/urbit/vere/dawn.c index 80a3856aa0..8a4aaf3ca4 100644 --- a/pkg/urbit/vere/dawn.c +++ b/pkg/urbit/vere/dawn.c @@ -506,6 +506,30 @@ _dawn_come(u3_noun stars) c3_c* who_c = u3r_string(who); u3l_log("boot: found comet %s\r\n", who_c); + + // enable to print and save comet private key for future reuse + // +#if 0 + { + u3_noun key = u3dc("scot", c3__uw, u3qe_jam(seed)); + c3_c* key_c = u3r_string(key); + + u3l_log("boot: comet private key\n %s\n", key_c); + + { + c3_c pat_c[64]; + snprintf(pat_c, 64, "%s.key", who_c + 1); + + FILE* fil_u = fopen(pat_c, "w"); + fprintf(fil_u, "%s\n", key_c); + fclose(fil_u); + } + + free(key_c); + u3z(key); + } +#endif + free(who_c); u3z(who); } From 2a29a10c9d184239da3f21d94804c45ffd48a2f9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 4 May 2019 21:22:12 -0700 Subject: [PATCH 3/4] fixes typo in daemon error printf --- pkg/urbit/vere/daemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/urbit/vere/daemon.c b/pkg/urbit/vere/daemon.c index bdf9e14e7e..16b5665aef 100644 --- a/pkg/urbit/vere/daemon.c +++ b/pkg/urbit/vere/daemon.c @@ -601,7 +601,7 @@ _boothack_key(u3_noun kef) u3_noun whu = u3dc("slaw", 'p', u3k(woh)); if ( u3_nul == whu ) { - u3l_log("dawn: invalid ship specificed with -w %s\r\n", + u3l_log("dawn: invalid ship specified with -w %s\r\n", u3_Host.ops_u.who_c); exit(1); } From 0e972f04c6efe7751d49dfaa8e7ba49fce171d21 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 6 May 2019 21:55:52 -0700 Subject: [PATCH 4/4] unmap the db on SIGABRT (for smaller core dump) --- pkg/urbit/daemon/main.c | 18 ++++++++++++++++++ pkg/urbit/include/vere/vere.h | 5 +++++ pkg/urbit/vere/pier.c | 10 +++++----- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/pkg/urbit/daemon/main.c b/pkg/urbit/daemon/main.c index 293f9c6c97..d6d197dcd8 100644 --- a/pkg/urbit/daemon/main.c +++ b/pkg/urbit/daemon/main.c @@ -467,6 +467,8 @@ report(void) printf("argon2: 0x%x\n", ARGON2_VERSION_NUMBER); } +/* _stop_exit(): exit immediately. +*/ static void _stop_exit(c3_i int_i) { @@ -476,6 +478,18 @@ _stop_exit(c3_i int_i) u3_daemon_bail(); } +/* _stop_trace(): print trace on SIGABRT. +*/ +static void +_stop_trace(c3_i int_i) +{ + // if we have a pier, unmap the event log before dumping core + // + if ( 0 != u3K.len_w ) { + u3_pier_db_shutdown(u3_pier_stub()); + } +} + /* This is set to the the write-end of a pipe when Urbit is started in daemon mode. It's meant to be used as a signal to the parent process @@ -626,6 +640,10 @@ main(c3_i argc, // signal(SIGTSTP, _stop_exit); + // Cleanup on SIGABRT. + // + signal(SIGABRT, _stop_trace); + printf("~\n"); // printf("welcome.\n"); printf("urbit %s\n", URBIT_VERSION); diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index 710f27710b..09bfe9aacf 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -1174,6 +1174,11 @@ /** Pier control. **/ + /* u3_pier_db_shutdown(): close the log. + */ + void + u3_pier_db_shutdown(u3_pier* pir_u); + /* u3_pier_interrupt(): interrupt running process. */ void diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index 9a5a3ad007..08889c0007 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -79,10 +79,10 @@ _pier_db_bail(void* vod_p, const c3_c* err_c) u3l_log("disk error: %s\r\n", err_c); } -/* _pier_db_shutdown(): close the log. +/* u3_pier_db_shutdown(): close the log. */ -static void -_pier_db_shutdown(u3_pier* pir_u) +void +u3_pier_db_shutdown(u3_pier* pir_u) { u3_lmdb_shutdown(pir_u->log_u->db_u); } @@ -844,7 +844,7 @@ _pier_work_exit(uv_process_t* req_u, u3l_log("pier: exit: status %" PRIu64 ", signal %d\r\n", sas_i, sig_i); uv_close((uv_handle_t*) req_u, 0); - _pier_db_shutdown(pir_u); + u3_pier_db_shutdown(pir_u); _pier_work_shutdown(pir_u); } @@ -1787,7 +1787,7 @@ _pier_exit_done(u3_pier* pir_u) { u3l_log("pier: exit\r\n"); - _pier_db_shutdown(pir_u); + u3_pier_db_shutdown(pir_u); _pier_work_shutdown(pir_u); _pier_loop_exit(pir_u);