From 6be29f01e5bed014aef3e590657e5e8fa71aa9af Mon Sep 17 00:00:00 2001 From: iphydf Date: Wed, 8 Nov 2023 14:40:12 +0000 Subject: [PATCH] chore: Add more logging to loading conferences from savedata. Better error messages than "something went wrong in type 20". Also fix bazel-asan/tsan builds. https://github.com/tweag/rules_nixpkgs/issues/442 is blocking fuzz tests under asan. --- .circleci/bazel-test | 7 ++++--- other/bootstrap_daemon/docker/tox-bootstrapd.sha256 | 2 +- testing/fuzzing/BUILD.bazel | 8 ++++---- toxcore/Messenger.c | 1 + toxcore/group.c | 4 ++++ toxcore/state.c | 2 +- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.circleci/bazel-test b/.circleci/bazel-test index b2d236d9..a1d9ef70 100755 --- a/.circleci/bazel-test +++ b/.circleci/bazel-test @@ -4,11 +4,12 @@ set -eux git submodule update --init --recursive /src/workspace/tools/inject-repo c-toxcore +# TODO(iphydf): Re-enable fuzz-test when https://github.com/tweag/rules_nixpkgs/issues/442 is fixed. cd /src/workspace && bazel test -k \ + --config=ci \ --config=remote \ - --build_tag_filters=-haskell \ - --test_tag_filters=-haskell \ - --remote_download_minimal \ + --build_tag_filters=-haskell,-fuzz-test \ + --test_tag_filters=-haskell,-fuzz-test \ -- \ //c-toxcore/... \ "$@" diff --git a/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 b/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 index 8ceccafe..2ccc4b84 100644 --- a/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 +++ b/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 @@ -1 +1 @@ -61c4cff326cf3a32fa5edad1c899c9eb586e4ebfcb8d11c9cf55d120fc7ab467 /usr/local/bin/tox-bootstrapd +036adfc1e993624ae0bf49f08c2890bb44e6d4224a07a8c7fd2e2b5a8be6bf4c /usr/local/bin/tox-bootstrapd diff --git a/testing/fuzzing/BUILD.bazel b/testing/fuzzing/BUILD.bazel index 386516d7..7144954b 100644 --- a/testing/fuzzing/BUILD.bazel +++ b/testing/fuzzing/BUILD.bazel @@ -28,7 +28,7 @@ cc_library( cc_fuzz_test( name = "bootstrap_fuzz_test", - #size = "small", + size = "small", srcs = ["bootstrap_harness.cc"], copts = ["-UNDEBUG"], corpus = ["//tools/toktok-fuzzer/corpus:bootstrap_fuzzer"], @@ -43,7 +43,7 @@ cc_fuzz_test( cc_fuzz_test( name = "e2e_fuzz_test", - #size = "small", + size = "small", srcs = ["e2e_fuzz_test.cc"], copts = ["-UNDEBUG"], corpus = ["//tools/toktok-fuzzer/corpus:e2e_fuzz_test"], @@ -59,7 +59,7 @@ cc_fuzz_test( cc_fuzz_test( name = "toxsave_fuzz_test", - #size = "small", + size = "small", srcs = ["toxsave_harness.cc"], copts = ["-UNDEBUG"], corpus = ["//tools/toktok-fuzzer/corpus:toxsave_fuzzer"], @@ -92,7 +92,7 @@ fuzzing_binary( cc_fuzz_test( name = "protodump_reduce", - #size = "small", + size = "small", srcs = ["protodump_reduce.cc"], copts = ["-UNDEBUG"], deps = [ diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index fc28e0c0..9e9f1146 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -2988,6 +2988,7 @@ static State_Load_Status load_nospam_keys(Messenger *m, const uint8_t *data, uin load_secret_key(m->net_crypto, data + sizeof(uint32_t) + CRYPTO_PUBLIC_KEY_SIZE); if (!pk_equal(data + sizeof(uint32_t), nc_get_self_public_key(m->net_crypto))) { + LOGGER_ERROR(m->log, "public key stored in savedata does not match its secret key"); return STATE_LOAD_STATUS_ERROR; } diff --git a/toxcore/group.c b/toxcore/group.c index 0e851b1e..40e81a11 100644 --- a/toxcore/group.c +++ b/toxcore/group.c @@ -802,6 +802,7 @@ static int addpeer(Group_Chats *g_c, uint32_t groupnumber, const uint8_t *real_p if (peer_index != -1) { if (!pk_equal(g->group[peer_index].real_pk, real_pk)) { + LOGGER_ERROR(g_c->m->log, "peer public key is incorrect for peer %d", peer_number); return -1; } @@ -3679,6 +3680,7 @@ static State_Load_Status load_conferences_helper(Group_Chats *g_c, const uint8_t if (groupnumber == -1) { // If this fails there's a serious problem, don't bother with cleanup + LOGGER_ERROR(g_c->m->log, "conference creation failed"); return STATE_LOAD_STATUS_ERROR; } @@ -3696,6 +3698,7 @@ static State_Load_Status load_conferences_helper(Group_Chats *g_c, const uint8_t assert(ret); } + LOGGER_ERROR(g_c->m->log, "conference loading failed"); return STATE_LOAD_STATUS_ERROR; } @@ -3705,6 +3708,7 @@ static State_Load_Status load_conferences_helper(Group_Chats *g_c, const uint8_t nullptr, true, false); if (peer_index == -1) { + LOGGER_ERROR(g_c->m->log, "adding peer %d failed", g->peer_number); return STATE_LOAD_STATUS_ERROR; } diff --git a/toxcore/state.c b/toxcore/state.c index 701cf442..e4f769ad 100644 --- a/toxcore/state.c +++ b/toxcore/state.c @@ -52,7 +52,7 @@ int state_load(const Logger *log, state_load_cb *state_load_callback, void *oute } case STATE_LOAD_STATUS_ERROR: { - LOGGER_ERROR(log, "Error occcured in state file (type: %u).", type); + LOGGER_ERROR(log, "Error occcured in state file (type: 0x%02x).", type); return -1; }