Merge branch 'cc-release' into cc-event-replay-check

This commit is contained in:
Joe Bryan 2019-04-25 17:04:39 -07:00 committed by GitHub
commit df59b1a489
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 229 additions and 80 deletions

1
.gitignore vendored
View File

@ -5,6 +5,7 @@
/zod
/fakezod*
tags
TAGS
bin/darwin
bin/linux32
bin/linux64

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e85cccf129bc9d03280d6142be58e56e230717c2ca9b8baeab38fb541e91b4f9
size 5280561
oid sha256:8e1b2d19d2b71a3c407358ff69b14de0029bd6a7c486b819f59274d615652917
size 5210146

View File

@ -5,7 +5,7 @@ set -ex
cp -r $FAKEZOD ./zod
chmod -R u+rw ./zod
urbit -d ./zod
$URBIT -d ./zod
cleanup () {
if [ -e ./zod/.vere.lock ]

View File

@ -1,10 +1,19 @@
{ pkgs, tlon, deps, urbit, fakezod, arvo }:
{ pkgs, tlon, deps, fakezod, arvo, debug }:
let
urbitExe = if debug
then "${tlon.urbit-debug}/bin/urbit-debug -g"
else "${tlon.urbit}/bin/urbit";
in
pkgs.stdenv.mkDerivation rec {
name = "brass";
builder = ./builder.sh;
buildInputs = [ urbit tlon.herb pkgs.coreutils ];
buildInputs = [ tlon.herb pkgs.coreutils ];
URBIT = urbitExe;
FAKEZOD = fakezod;
ARVO = arvo;
}

View File

@ -1,4 +1,4 @@
{ pkgs ? import ../nixpkgs.nix }:
{ pkgs ? import ../nixpkgs.nix, debug ? false }:
let
@ -12,34 +12,34 @@ in
rec {
bootzod = import ./fakeship {
inherit pkgs tlon deps urbit;
inherit pkgs tlon deps debug;
brass = ../../bin/brass.pill;
ship = "zod";
};
bootbus = import ./fakeship {
inherit pkgs tlon deps urbit;
inherit pkgs tlon deps debug;
brass = ../../bin/brass.pill;
ship = "bus";
};
test = import ./test {
inherit pkgs tlon deps urbit arvo;
inherit pkgs tlon deps arvo debug;
ship = bootzod;
};
solid = import ./solid {
inherit arvo pkgs tlon deps urbit;
inherit arvo pkgs tlon deps debug;
fakezod = bootzod;
};
brass = import ./brass {
inherit arvo pkgs tlon deps urbit;
inherit arvo pkgs tlon deps debug;
fakezod = bootzod;
};
fakezod = import ./fakeship {
inherit pkgs tlon deps urbit brass;
inherit pkgs tlon deps brass debug;
ship = "zod";
};

View File

@ -2,7 +2,7 @@ source $stdenv/setup
set -ex
urbit -d -F $SHIP -B "$PILL" $out
$URBIT -d -F $SHIP -B "$PILL" $out
check () {
[ 3 -eq "$(herb $out -d 3)" ]

View File

@ -1,9 +1,18 @@
{ pkgs, tlon, deps, urbit, brass, ship ? "zod" }:
{ pkgs, tlon, deps, brass, ship, debug }:
pkgs.stdenv.mkDerivation rec {
let
urbitExe = if debug
then "${tlon.urbit-debug}/bin/urbit-debug -g"
else "${tlon.urbit}/bin/urbit";
in
pkgs.stdenv.mkDerivation {
name = "fake" + ship;
builder = ./builder.sh;
buildInputs = [ urbit tlon.herb ];
buildInputs = [ tlon.herb ];
URBIT = urbitExe;
PILL = brass;
SHIP = ship;
}

View File

@ -5,7 +5,7 @@ set -ex
cp -r $FAKEZOD ./zod
chmod -R u+rw ./zod
urbit -d ./zod
$URBIT -d ./zod
cleanup () {
if [ -e ./zod/.vere.lock ]

View File

@ -1,10 +1,19 @@
{ pkgs, tlon, deps, urbit, fakezod, arvo }:
{ pkgs, tlon, deps, fakezod, arvo, debug }:
let
urbitExe = if debug
then "${tlon.urbit-debug}/bin/urbit-debug -g"
else "${tlon.urbit}/bin/urbit";
in
pkgs.stdenv.mkDerivation rec {
name = "solid";
builder = ./builder.sh;
buildInputs = [ urbit tlon.herb pkgs.coreutils ];
buildInputs = [ tlon.herb ];
URBIT = urbitExe;
FAKEZOD = fakezod;
ARVO = arvo;
}

View File

@ -5,7 +5,7 @@ set -ex
cp -r $SHIP ./ship
chmod -R u+rw ./ship
urbit -d ./ship 2> urbit-output
$URBIT -d ./ship 2> urbit-output
tail -f urbit-output >&2 &
tailproc=$!

View File

@ -1,10 +1,19 @@
{ pkgs, tlon, deps, urbit, ship, arvo }:
{ pkgs, tlon, deps, ship, arvo, debug }:
let
urbitExe = if debug
then "${tlon.urbit-debug}/bin/urbit-debug -g"
else "${tlon.urbit}/bin/urbit";
in
pkgs.stdenv.mkDerivation rec {
name = "test";
builder = ./builder.sh;
buildInputs = [ urbit tlon.herb pkgs.coreutils ];
buildInputs = [ tlon.herb ];
SHIP = ship;
ARVO = arvo;
URBIT = urbitExe;
SHIP = ship;
ARVO = arvo;
}

View File

@ -7,7 +7,7 @@ cd src
bash ./configure
make clean
make urbit urbit-worker -j8
make all -j8
make test
mkdir -p $out/bin

View File

@ -29,7 +29,7 @@ pkgs.stdenv.mkDerivation {
# See https://github.com/NixOS/nixpkgs/issues/18995
hardeningDisable = if debug then [ "all" ] else [];
CFLAGS = if debug then "-O0 -g" else "-O3";
CFLAGS = if debug then "-O1 -g" else "-O3";
MEMORY_DEBUG = debug;
CPU_DEBUG = debug;
EVENT_TIME_DEBUG = false;

@ -1 +1 @@
Subproject commit 46c92473477ba8f4d14a6e2bb22319c8bf5970a4
Subproject commit 587b4d26df6396a21478a110fc0736df319298a0

View File

@ -17,6 +17,12 @@ all_objs = $(common_objs) $(daemon_objs) $(worker_objs)
all_srcs = $(common) $(daemon) $(worker)
all_exes = ./hash_tests ./hashtable_tests ./urbit ./urbit-worker
# -Werror promotes all warnings that are enabled into errors (this is on)
# -Wall issues all types of errors. This is off (for now)
CFLAGS := $(CFLAGS) -Werror
################################################################################
.PHONY: all test clean mkproper

View File

@ -1,18 +0,0 @@
#ifndef CONFIG_H
#define CONFIG_H
#mesondefine URBIT_VERSION
#mesondefine U3_OS_linux
#mesondefine U3_OS_bsd
#mesondefine U3_OS_osx
#mesondefine U3_OS_ENDIAN_little
#mesondefine U3_OS_ENDIAN_big
#mesondefine U3_MEMORY_DEBUG
#mesondefine U3_CPU_DEBUG
#mesondefine U3_EVENT_TIME_DEBUG
#mesondefine U3_MEMORY_LOG
#endif /*CONFIG_H*/

View File

@ -603,6 +603,7 @@
struct _u3_pier* pir_u; // backpointer to pier
u3_noun job; // (pair date ovum)
c3_d evt_d; // event number
c3_d rep_d; // replacement count
u3_noun now; // event time
c3_l msc_l; // ms to timeout
c3_l mug_l; // hash before executing
@ -1273,6 +1274,10 @@
void
u3_daemon_grab(void* vod_p);
c3_w
u3_readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
/* Database
*/
/* u3_lmdb_init(): Initializes lmdb inside log_path
@ -1326,3 +1331,5 @@
u3_noun* who,
u3_noun* is_fake,
u3_noun* life);

View File

@ -633,12 +633,22 @@ _ce_patch_apply(u3_ce_patch* pat_u)
//u3l_log("image: sou_w %d, new %d\r\n", u3P.sou_u.pgs_w, pat_u->con_u->sou_w);
if ( u3P.nor_u.pgs_w > pat_u->con_u->nor_w ) {
ftruncate(u3P.nor_u.fid_i, u3P.nor_u.pgs_w << (u3a_page + 2));
c3_w ret_w;
ret_w = ftruncate(u3P.nor_u.fid_i, u3P.nor_u.pgs_w << (u3a_page + 2));
if (ret_w){
perror("_ce_patch_apply");
c3_assert(0);
}
}
u3P.nor_u.pgs_w = pat_u->con_u->nor_w;
if ( u3P.sou_u.pgs_w > pat_u->con_u->sou_w ) {
ftruncate(u3P.sou_u.fid_i, u3P.sou_u.pgs_w << (u3a_page + 2));
c3_w ret_w;
ret_w = ftruncate(u3P.sou_u.fid_i, u3P.sou_u.pgs_w << (u3a_page + 2));
if (ret_w){
perror("_ce_patch_apply");
c3_assert(0);
}
}
u3P.sou_u.pgs_w = pat_u->con_u->sou_w;

View File

@ -478,7 +478,7 @@ u3i_list(u3_weak one, ...);
return cut_t ? cut_w : i_w;
}
__attribute__((no_sanitize("address")))
__attribute__((no_sanitize_address))
static u3_noun // transfer
_molt_apply(u3_noun som, // retain
c3_w len_w,
@ -504,7 +504,7 @@ u3i_list(u3_weak one, ...);
}
}
__attribute__((no_sanitize("address")))
__attribute__((no_sanitize_address))
u3_noun
u3i_molt(u3_noun som, ...)
{

View File

@ -94,19 +94,28 @@ _cm_punt(u3_noun tax)
}
#endif
static void _write(int fd, const void *buf, size_t count)
{
if (count != write(fd, buf, count)){
u3l_log("write failed\r\n");
c3_assert(0);
}
}
/* _cm_emergency(): write emergency text to stderr, never failing.
*/
static void
_cm_emergency(c3_c* cap_c, c3_l sig_l)
{
write(2, "\r\n", 2);
write(2, cap_c, strlen(cap_c));
_write(2, "\r\n", 2);
_write(2, cap_c, strlen(cap_c));
if ( sig_l ) {
write(2, ": ", 2);
write(2, &sig_l, 4);
_write(2, ": ", 2);
_write(2, &sig_l, 4);
}
write(2, "\r\n", 2);
_write(2, "\r\n", 2);
}
static void _cm_overflow(void *arg1, void *arg2, void *arg3)

View File

@ -161,7 +161,7 @@ u3r_at(u3_atom a, u3_noun b)
}
}
__attribute__((no_sanitize("address")))
__attribute__((no_sanitize_address))
c3_o
u3r_mean(u3_noun som,
...)

View File

@ -6,6 +6,10 @@ static void _test_cache_trimming(void);
static void _test_no_cache(void);
static void _test_skip_slot(void);
// defined in noun/hashtable.c
c3_w _ch_skip_slot(c3_w mug_w, c3_w lef_w);
/* main(): run all test cases.
*/
int

View File

@ -694,6 +694,12 @@ _pier_work_replace(u3_writ* wit_u,
c3_assert(god_u->sen_d == wit_u->evt_d);
// something has gone very wrong, we should probably stop now
//
if ( wit_u->rep_d >= 3ULL ) {
u3_pier_bail();
}
/* move backward in work processing
*/
{
@ -704,7 +710,9 @@ _pier_work_replace(u3_writ* wit_u,
wit_u->mat = u3ke_jam(u3nc(wit_u->mug_l,
u3k(wit_u->job)));
god_u->sen_d -= 1;
wit_u->rep_d += 1ULL;
god_u->sen_d -= 1ULL;
}
if ( wit_u->evt_d > pir_u->lif_d ) {
@ -1156,6 +1164,18 @@ _pier_loop_wake(u3_pier* pir_u)
{
c3_l cod_l;
// inject fresh entropy
//
{
c3_w eny_w[16];
c3_rand(eny_w);
u3_noun wir = u3nt(u3_blip, c3__arvo, u3_nul);
u3_noun car = u3nc(c3__wack, u3i_words(16, eny_w));
_pier_writ_insert_ovum(pir_u, 0, u3nc(wir, car));
}
cod_l = u3a_lush(c3__unix);
u3_unix_io_talk(pir_u);
u3_unix_ef_bake(pir_u);
@ -1373,8 +1393,6 @@ _pier_boot_vent(u3_boot* bot_u)
// prepend entropy to the module sequence
//
// XX also copy to _pier_loop_wake?
//
{
c3_w eny_w[16];
c3_rand(eny_w);

View File

@ -27,6 +27,15 @@ static u3_utty* _term_main();
#define _SPIN_RATE_US 250000 // spinner rate (microseconds/frame)
#define _SPIN_IDLE_US 500000 // spinner cools down if stopped this long
static void _write(int fd, const void *buf, size_t count)
{
if (count != write(fd, buf, count)){
u3l_log("write failed\r\n");
c3_assert(0);
}
}
/* _term_msc_out_host(): unix microseconds from current host time.
*/
static c3_d
@ -291,7 +300,7 @@ u3_term_io_exit(void)
if ( -1 == fcntl(uty_u->fid_i, F_SETFL, uty_u->cug_i) ) {
c3_assert(!"exit-fcntl");
}
write(uty_u->fid_i, "\r\n", 2);
_write(uty_u->fid_i, "\r\n", 2);
#if 0
if ( uty_u->tat_u.sun.sit_u ) {
@ -765,7 +774,7 @@ _term_try_write_str(u3_utty* uty_u,
{
// c3_i fid_i = uv_fileno(&uty_u->pop_u);
c3_i fid_i = uty_u->pop_u.io_watcher.fd; // XX old libuv
write(fid_i, hun_y, strlen(hun_y));
_write(fid_i, hun_y, strlen(hun_y));
}
/* _term_try_move_left(): move the cursor left (off-thread).
@ -1219,8 +1228,8 @@ u3_term_io_hija(void)
perror("hija-fcntl-0");
c3_assert(!"hija-fcntl");
}
write(uty_u->fid_i, "\r", 1);
write(uty_u->fid_i, uty_u->ufo_u.out.el_y,
_write(uty_u->fid_i, "\r", 1);
_write(uty_u->fid_i, uty_u->ufo_u.out.el_y,
strlen((c3_c*) uty_u->ufo_u.out.el_y));
}
return stdout;

View File

@ -15,6 +15,23 @@
#include "vere/vere.h"
c3_w u3_readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
{
errno = 0;
struct dirent * tmp_u = readdir(dirp);
if (NULL == tmp_u){
*result = NULL;
return (errno); // either success or error code
} else {
memcpy(entry, tmp_u, sizeof(struct dirent));
*result = entry;
}
return(0);
}
/* _unix_down(): descend path.
*/
static c3_c*
@ -311,9 +328,10 @@ _unix_scan_mount_point(u3_pier *pir_u, u3_umon* mon_u)
struct dirent* out_u;
c3_w err_w;
if ( 0 != (err_w = readdir_r(rid_u, &ent_u, &out_u)) ) {
if ( 0 != (err_w = u3_readdir_r(rid_u, &ent_u, &out_u)) ) {
u3l_log("erroring loading pier directory %s: %s\r\n",
mon_u->dir_u.pax_c, strerror(errno));
c3_assert(0);
}
else if ( !out_u ) {
@ -756,7 +774,8 @@ _unix_update_dir(u3_pier *pir_u, u3_udir* dir_u)
struct dirent* out_u;
c3_w err_w;
if ( (err_w = readdir_r(rid_u, &ent_u, &out_u)) != 0 ) {
if ( (err_w = u3_readdir_r(rid_u, &ent_u, &out_u)) != 0 ) {
u3l_log("error loading directory %s: %s\r\n",
dir_u->pax_c, strerror(err_w));
c3_assert(0);
@ -948,9 +967,10 @@ _unix_initial_update_dir(c3_c* pax_c, c3_c* bas_c)
struct dirent* out_u;
c3_w err_w;
if ( 0 != (err_w = readdir_r(rid_u, &ent_u, &out_u)) ) {
if ( 0 != (err_w = u3_readdir_r(rid_u, &ent_u, &out_u)) ) {
u3l_log("error loading initial directory %s: %s\r\n",
pax_c, strerror(errno));
c3_assert(0);
}
else if ( !out_u ) {

View File

@ -192,8 +192,8 @@ _walk_in(const c3_c* dir_c, c3_w len_w)
struct dirent ent_n;
struct dirent* out_n;
if ( readdir_r(dir_d, &ent_n, &out_n) != 0 ) {
u3l_log("%s: %s\n", dir_c, strerror(errno));
if ( u3_readdir_r(dir_d, &ent_n, &out_n) != 0 ) {
u3l_log("%s: %s\n", dir_c, strerror(errno));
break;
}
else if ( !out_n ) {

View File

@ -328,7 +328,7 @@ _worker_grab(u3_noun sac, u3_noun ovo, u3_noun vir)
static void
_worker_fail(void* vod_p, const c3_c* wut_c)
{
u3l_log("worker: fail: %s\r\n", wut_c);
u3l_log("work: fail: %s\r\n", wut_c);
exit(1);
}
@ -388,10 +388,56 @@ _worker_send_slog(u3_noun hod)
static void
_worker_lame(c3_d evt_d, u3_noun ovo, u3_noun why, u3_noun tan)
{
// %crud will be sent on the original wire.
u3_noun rep;
u3_noun wir, tag, cad;
u3x_trel(ovo, &wir, &tag, &cad);
// a deterministic error (%exit) in a network packet (%hear)
// generates a negative-acknowlegement attempt (%hole).
//
_worker_send_replace(evt_d, u3nc(u3k(u3h(ovo)), u3nt(c3__crud, why, tan)));
u3z(ovo);
// A comment from the old implementation:
// There should be a separate path for crypto failures,
// to prevent timing attacks, but isn't right now. To deal
// with a crypto failure, just drop the packet.
//
if ( (c3__hear == tag) && (c3__exit == why) ) {
rep = u3nt(u3k(wir), c3__hole, u3k(cad));
}
// failed event notifications (%crud) are replaced with
// an even more generic notifications, on a generic arvo wire.
// N.B this must not be allowed to fail!
//
// [%warn original-event-tag=@tas combined-trace=(list tank)]
//
else if ( c3__crud == tag ) {
u3_noun lef = u3nc(c3__leaf, u3i_tape("crude crashed!"));
u3_noun nat = u3kb_weld(u3k(u3t(cad)), u3nc(lef, u3k(tan)));
rep = u3nc(u3nt(u3_blip, c3__arvo, u3_nul),
u3nt(c3__warn, u3k(u3h(cad)), nat));
}
// failed failure failing fails
//
else if ( c3__warn == tag ) {
_worker_fail(0, "%warn replacement event failed");
c3_assert(0);
}
// failure notifications are sent on the same wire
//
// [%crud event-tag=@tas event-trace=(list tank)]
//
else {
// prepend failure mote to tank
//
u3_noun lef = u3nc(c3__leaf, u3kb_weld(u3i_tape("bail: "),
u3qc_rip(3, why)));
u3_noun nat = u3kb_weld(u3k(tan), u3nc(lef, u3_nul));
rep = u3nc(u3k(wir), u3nt(c3__crud, u3k(tag), nat));
}
_worker_send_replace(evt_d, rep);
u3z(ovo); u3z(why); u3z(tan);
}
/* _worker_sure(): event succeeded, report completion.
@ -482,7 +528,7 @@ _worker_work_live(c3_d evt_d, // event number
if ( c3__belt != u3h(u3t(ovo)) ) {
c3_c* txt_c = u3r_string(u3h(u3t(ovo)));
u3l_log("worker: %s (%" PRIu64 ") live\r\n", txt_c, evt_d);
u3l_log("work: %s (%" PRIu64 ") live\r\n", txt_c, evt_d);
}
}
#endif
@ -564,8 +610,8 @@ _worker_boot_fire(u3_noun eve)
*/
static void
_worker_work_boot(c3_d evt_d,
c3_l mug_l,
u3_noun job)
c3_l mug_l,
u3_noun job)
{
c3_assert(evt_d == u3V.evt_d + 1ULL);
if ( 0 != mug_l ) {
@ -576,7 +622,7 @@ _worker_work_boot(c3_d evt_d,
u3A->roe = u3nc(job, u3A->roe);
u3l_log("worker: (%" PRIu64 ")| boot\r\n", evt_d);
u3l_log("work: (%" PRIu64 ")| boot\r\n", evt_d);
if ( u3V.len_w == evt_d ) {
u3_noun eve, pru;
@ -584,7 +630,7 @@ _worker_work_boot(c3_d evt_d,
eve = u3kb_flop(u3A->roe);
u3A->roe = 0;
u3l_log("worker: (%" PRIu64 ")| pill: %x\r\n", evt_d, u3r_mug(eve));
u3l_log("work: (%" PRIu64 ")| pill: %x\r\n", evt_d, u3r_mug(eve));
pru = u3m_soft(0, _worker_boot_fire, eve);
@ -616,8 +662,8 @@ _worker_work_boot(c3_d evt_d,
*/
static void
_worker_poke_work(c3_d evt_d, // event number
c3_l mug_l, // mug of state
u3_noun job) // full event
c3_l mug_l, // mug of state
u3_noun job) // full event
{
if ( u3C.wag_w & u3o_trace ) {
if ( u3_Host.tra_u.con_w == 0 && u3_Host.tra_u.fun_w == 0 ) {
@ -773,6 +819,7 @@ _worker_poke(void* vod_p, u3_noun mat)
evt_d = u3r_chub(0, evt);
u3z(evt);
u3z(jar);
c3_assert( evt_d == u3V.evt_d );
@ -813,7 +860,7 @@ u3_worker_boot(void)
u3V.len_w = 0;
}
u3l_log("worker: play %" PRIu64 "\r\n", nex_d);
u3l_log("work: play %" PRIu64 "\r\n", nex_d);
_worker_send(u3nc(c3__play, dat));
}

View File

@ -2,7 +2,7 @@
set -e
pkg=$(nix-build nix/ops -A test --no-out-link)
pkg=$(nix-build nix/ops -A test --no-out-link --arg debug true)
hdr () {
echo =====$(sed 's/./=/g' <<< "$1")=====