diff --git a/c/compiler.cmake b/c/compiler.cmake index 53235f1fe..cfc42ca98 100644 --- a/c/compiler.cmake +++ b/c/compiler.cmake @@ -12,6 +12,10 @@ endif(MSVC) if (WASM) set (CMAKE_C_FLAGS "-Wall -funsigned-char -Wextra -std=c99") set (CMAKE_CXX_FLAGS "-Wall -funsigned-char -Wextra -std=c99 -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'") + if (CMAKE_BUILD_TYPE MATCHES Debug) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined,address -fsanitize-minimal-runtime") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined,address -fsanitize-minimal-runtime") + endif() else (WASM) set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif(WASM) diff --git a/c/src/api/usn/usn_api.c b/c/src/api/usn/usn_api.c index c7c54b5da..c2090187c 100644 --- a/c/src/api/usn/usn_api.c +++ b/c/src/api/usn/usn_api.c @@ -349,9 +349,9 @@ static int usn_add_booking(usn_device_t* device, address_t controller, uint64_t return 0; } } - device->bookings = device->bookings - ? _realloc(device->bookings, sizeof(usn_booking_t) * (device->num_bookings + 1), sizeof(usn_booking_t) * device->num_bookings) - : _malloc(sizeof(usn_booking_t) * device->num_bookings + 1); + device->bookings = device->bookings + ? _realloc(device->bookings, sizeof(usn_booking_t) * (device->num_bookings + 1), sizeof(usn_booking_t) * device->num_bookings) + : _malloc(sizeof(usn_booking_t) * device->num_bookings + 1); usn_booking_t* booking = device->bookings + device->num_bookings; booking->rented_from = rented_from; booking->rented_until = rented_until; diff --git a/c/src/cmd/in3/main.c b/c/src/cmd/in3/main.c index 31a810f71..0b7c0aa70 100644 --- a/c/src/cmd/in3/main.c +++ b/c/src/cmd/in3/main.c @@ -708,6 +708,13 @@ int main(int argc, char* argv[]) { #ifndef USE_CURL c->flags |= FLAGS_HTTP; #endif + // handle clear cache opt before initializing cache + for (i = 1; i < argc; i++) + if (strcmp(argv[i], "-fi") == 0) { + recorder_update_cmd(argv[i + 1], &argc, &argv); + break; + } + // handle clear cache opt before initializing cache for (i = 1; i < argc; i++) if (strcmp(argv[i], "-ccache") == 0) @@ -768,7 +775,7 @@ int main(int argc, char* argv[]) { else if (strcmp(argv[i], "-thr") == 0) run_test_request = 2; else if (strcmp(argv[i], "-fo") == 0) - recorder_write_start(c, argv[++i]); + recorder_write_start(c, argv[++i], argc, argv); else if (strcmp(argv[i], "-fi") == 0) recorder_read_start(c, argv[++i]); else if (strcmp(argv[i], "-nl") == 0) diff --git a/c/src/cmd/in3/recorder.c b/c/src/cmd/in3/recorder.c index 8064c923c..af8b2f11f 100644 --- a/c/src/cmd/in3/recorder.c +++ b/c/src/cmd/in3/recorder.c @@ -3,10 +3,15 @@ #include "../../core/client/keys.h" #include #include -static void die(char* msg) { - fprintf(stderr, COLORT_RED "Error: %s" COLORT_RESET "\n", msg); - exit(EXIT_FAILURE); -} + +typedef struct recorder_entry { + char* name; + char** args; + int argl; + sb_t content; + struct recorder_entry* next; + +} recorder_entry_t; typedef struct { char* file; @@ -14,20 +19,15 @@ typedef struct { FILE* f; in3_storage_handler_t* cache; uint64_t time; + recorder_entry_t* queue; } recorder_t; -typedef struct { - char* name; - char** args; - int argl; - -} recorder_entry_t; - static recorder_t rec = { .file = NULL, .transport = NULL, .f = NULL, .cache = NULL, + .queue = NULL, .time = 0}; static int rand_out(void* s) { @@ -38,64 +38,89 @@ static int rand_out(void* s) { return r; } -recorder_entry_t read_entry(sb_t* sb) { - recorder_entry_t entry = {0}; +static inline bool match(recorder_entry_t* entry, const char* type, const char* first_arg) { + return entry && entry->name && strcmp(type, entry->name) == 0 && (first_arg == NULL || (entry->argl && strcmp(entry->args[0], first_arg) == 0)); +} - char buffer[1024]; +static recorder_entry_t* read_one_entry() { + recorder_entry_t* entry = NULL; + char buffer[1024]; while (fgets(buffer, 1023, rec.f)) { int l = strlen(buffer); if (buffer[l - 1] == '\n') buffer[--l] = 0; if (!l) break; - if (!entry.name) { - char* ptr = strtok(buffer + 3, " "); - entry.name = _strdupn(ptr, -1); + if (!entry) { + entry = _calloc(sizeof(recorder_entry_t), 1); + char* ptr = strtok(buffer + 3, " "); + entry->name = _strdupn(ptr, -1); while ((ptr = strtok(NULL, " "))) { - entry.args = entry.argl ? _realloc(entry.args, sizeof(char*) * (entry.argl + 1), sizeof(char*) * entry.argl) : _malloc(sizeof(char*)); - entry.args[entry.argl++] = _strdupn(ptr, -1); + entry->args = entry->argl ? _realloc(entry->args, sizeof(char*) * (entry->argl + 1), sizeof(char*) * entry->argl) : _malloc(sizeof(char*)); + entry->args[entry->argl++] = _strdupn(ptr, -1); } } else - sb_add_chars(sb, buffer); + sb_add_chars(&entry->content, buffer); } - return entry; } -static void entry_free(recorder_entry_t* e, sb_t* sb) { + +recorder_entry_t* next_entry(const char* type, const char* firs_arg) { + + recorder_entry_t *last = rec.queue, *end = NULL; + for (recorder_entry_t* n = last; n; last = n, n = n->next) { + if (match((end = n), type, firs_arg)) { + if (last == n) + rec.queue = n->next; + else + last->next = n->next; + return n; + } + } + + do { + if (match((last = read_one_entry()), type, firs_arg)) + return last; + if (!last) { + fprintf(stderr, COLORT_RED "Error: expected entry %s %s but did not find it!" COLORT_RESET "\n", type, firs_arg ? firs_arg : ""); + exit(EXIT_FAILURE); + } + if (end) + end->next = last; + else + rec.queue = last; + end = last; + + } while (true); +} + +static void entry_free(recorder_entry_t* e) { if (e->name) _free(e->name); for (int i = 0; i < e->argl; i++) _free(e->args[i]); _free(e->args); - if (sb && sb->data) _free(sb->data); - if (sb) *sb = (sb_t){0}; + if (e->content.data) _free(e->content.data); + _free(e); } static int rand_in(void* s) { UNUSED_VAR(s); - sb_t sb = {0}; - recorder_entry_t entry = read_entry(&sb); - if (!entry.name || strcmp(entry.name, "rand")) die("expected rand in recorder!"); - if (entry.argl != 1) die("expect one arg for random"); - int r = atoi(entry.args[0]); - entry_free(&entry, &sb); - + recorder_entry_t* entry = next_entry("rand", NULL); + int r = atoi(entry->args[0]); + entry_free(entry); return r; } static in3_ret_t recorder_transport_in(in3_request_t* req) { - sb_t sb = {0}; - recorder_entry_t entry = {0}; + if (req->action == REQ_ACTION_SEND) { - entry = read_entry(&sb); - if (!entry.name || strcmp(entry.name, "request")) die("expected request in recorder!"); - entry_free(&entry, &sb); + entry_free(next_entry("request", NULL)); req->cptr = &rec; } if (req->action != REQ_ACTION_CLEANUP) { - entry = read_entry(&sb); - if (!entry.name || strcmp(entry.name, "response")) die("expected response in recorder!"); - in3_response_t* r = req->ctx->raw_response + atoi(entry.args[0]); - sb_add_chars(&r->data, sb.data); - r->state = atoi(entry.args[3]); - r->time = atoi(entry.args[4]); - entry_free(&entry, &sb); + recorder_entry_t* entry = next_entry("response", d_get_stringk(req->ctx->requests[0], K_METHOD)); + in3_response_t* r = req->ctx->raw_response + atoi(entry->args[1]); + sb_add_chars(&r->data, entry->content.data); + r->state = atoi(entry->args[3]); + r->time = atoi(entry->args[4]); + entry_free(entry); } return 0; @@ -116,7 +141,7 @@ static in3_ret_t recorder_transport_out(in3_request_t* req) { for (int i = 0; m; i++, m = m->next) { in3_response_t* r = req->ctx->raw_response + i; if (r->time) { - fprintf(rec.f, ":: response %i %s %s %i %i\n", i, d_get_stringk(req->ctx->requests[0], K_METHOD), ctx_get_node(chain, m)->url, r->state, r->time); + fprintf(rec.f, ":: response %s %i %s %i %i\n", d_get_stringk(req->ctx->requests[0], K_METHOD), i, ctx_get_node(chain, m)->url, r->state, r->time); char* data = format_json(r->data.data ? r->data.data : ""); fprintf(rec.f, "%s\n\n", data); fflush(rec.f); @@ -130,13 +155,9 @@ static in3_ret_t recorder_transport_out(in3_request_t* req) { bytes_t* rec_get_item_in(void* cptr, const char* key) { UNUSED_VAR(cptr); UNUSED_VAR(key); - sb_t sb = {0}; - recorder_entry_t entry = read_entry(&sb); - if (!entry.name || strcmp(entry.name, "cache")) die("expected cache in recorder!"); - if (entry.argl != 2) die("expect 2 args for cache"); - if (strcmp(key, entry.args[0])) die("wrong cache key"); - bytes_t* found = atoi(entry.args[1]) ? hex_to_new_bytes(sb.data, sb.len) : NULL; - entry_free(&entry, &sb); + recorder_entry_t* entry = next_entry("cache", key); + bytes_t* found = atoi(entry->args[1]) ? hex_to_new_bytes(entry->content.data, entry->content.len) : NULL; + entry_free(entry); return found; } @@ -177,13 +198,16 @@ uint64_t static_time(void* t) { return rec.time; } -void recorder_write_start(in3_t* c, char* file) { +void recorder_write_start(in3_t* c, char* file, int argc, char* argv[]) { rec.file = file; rec.transport = c->transport; c->transport = recorder_transport_out; rec.f = fopen(file, "w"); rec.cache = c->cache; in3_set_func_rand(rand_out); + fprintf(rec.f, ":: cmd"); + for (int i = 0; i < argc; i++) fprintf(rec.f, " %s", strcmp(argv[i], "-fo") ? argv[i] : "-fi"); + fprintf(rec.f, "\n\n"); in3_set_storage_handler(c, rec_get_item_out, rec_set_item_out, rec_clear_out, &rec); fprintf(rec.f, ":: time %u\n\n", (uint32_t) in3_time(NULL)); } @@ -195,9 +219,22 @@ void recorder_read_start(in3_t* c, char* file) { rec.f = fopen(file, "r"); in3_set_func_rand(rand_in); in3_set_storage_handler(c, rec_get_item_in, rec_set_item_in, rec_clear_in, &rec); - sb_t sb = {0}; - recorder_entry_t entry = read_entry(&sb); - rec.time = entry.argl >= 1 ? atoll(entry.args[0]) : 0; - entry_free(&entry, &sb); + recorder_entry_t* entry = next_entry("time", NULL); + rec.time = entry->argl >= 1 ? atoll(entry->args[0]) : 0; + entry_free(entry); in3_set_func_time(static_time); } + +void recorder_update_cmd(char* file, int* argc, char** argv[]) { + rec.file = file; + rec.f = fopen(file, "r"); + recorder_entry_t* entry = next_entry("cmd", NULL); + *argc = entry->argl; + *argv = entry->args; + for (int i = 0; i < entry->argl; i++) { + if (strcmp(entry->args[i], "-fi") == 0) entry->args[i + 1] = file; + } + fclose(rec.f); + rec.f = NULL; + rec.queue = NULL; +} \ No newline at end of file diff --git a/c/src/cmd/in3/recorder.h b/c/src/cmd/in3/recorder.h index 41b13fe1b..c3941edcc 100644 --- a/c/src/cmd/in3/recorder.h +++ b/c/src/cmd/in3/recorder.h @@ -7,5 +7,6 @@ #include #include -void recorder_write_start(in3_t* c, char* file); +void recorder_write_start(in3_t* c, char* file, int argc, char* argv[]); void recorder_read_start(in3_t* c, char* file); +void recorder_update_cmd(char* file, int* argc, char** argv[]); \ No newline at end of file diff --git a/c/src/core/client/client.h b/c/src/core/client/client.h index ab46e7d7f..a07526576 100644 --- a/c/src/core/client/client.h +++ b/c/src/core/client/client.h @@ -280,10 +280,10 @@ typedef struct in3_storage_handler { void* cptr; /**< custom pointer which will be passed to functions */ } in3_storage_handler_t; -#define IN3_SIGN_ERR_REJECTED -1 /**< return value used by the signer if the the signature-request was rejected. */ +#define IN3_SIGN_ERR_REJECTED -1 /**< return value used by the signer if the the signature-request was rejected. */ #define IN3_SIGN_ERR_ACCOUNT_NOT_FOUND -2 /**< return value used by the signer if the requested account was not found. */ -#define IN3_SIGN_ERR_INVALID_MESSAGE -3 /**< return value used by the signer if the message was invalid. */ -#define IN3_SIGN_ERR_GENERAL_ERROR -4 /**< return value used by the signer for unspecified errors. */ +#define IN3_SIGN_ERR_INVALID_MESSAGE -3 /**< return value used by the signer if the message was invalid. */ +#define IN3_SIGN_ERR_GENERAL_ERROR -4 /**< return value used by the signer for unspecified errors. */ /** type of the requested signature */ typedef enum { diff --git a/c/src/core/client/client_init.c b/c/src/core/client/client_init.c index 39d701012..c9c3c08b6 100644 --- a/c/src/core/client/client_init.c +++ b/c/src/core/client/client_init.c @@ -383,9 +383,9 @@ in3_ret_t in3_client_add_node(in3_t* c, chain_id_t chain_id, char* url, in3_node chain->nodelist = chain->nodelist ? _realloc(chain->nodelist, sizeof(in3_node_t) * (chain->nodelist_length + 1), sizeof(in3_node_t) * chain->nodelist_length) : _calloc(chain->nodelist_length + 1, sizeof(in3_node_t)); - chain->weights = chain->weights - ? _realloc(chain->weights, sizeof(in3_node_weight_t) * (chain->nodelist_length + 1), sizeof(in3_node_weight_t) * chain->nodelist_length) - : _calloc(chain->nodelist_length + 1, sizeof(in3_node_weight_t)); + chain->weights = chain->weights + ? _realloc(chain->weights, sizeof(in3_node_weight_t) * (chain->nodelist_length + 1), sizeof(in3_node_weight_t) * chain->nodelist_length) + : _calloc(chain->nodelist_length + 1, sizeof(in3_node_weight_t)); if (!chain->nodelist || !chain->weights) return IN3_ENOMEM; node = chain->nodelist + chain->nodelist_length; node->address = b_new(address, 20); diff --git a/c/src/core/client/context.c b/c/src/core/client/context.c index 0e556637d..c79be3e25 100644 --- a/c/src/core/client/context.c +++ b/c/src/core/client/context.c @@ -82,11 +82,13 @@ char* ctx_get_error_data(in3_ctx_t* ctx) { } char* ctx_get_response_data(in3_ctx_t* ctx) { - str_range_t rr = d_to_json(ctx->responses[0]), rin3; - if ((ctx->client->flags & FLAGS_KEEP_IN3) == 0 && (rin3 = d_to_json(d_get(ctx->responses[0], K_IN3))).data) { - while (*rin3.data != ',' && rin3.data > rr.data) rin3.data--; - *rin3.data = '}'; - rr.len = rin3.data - rr.data + 1; + str_range_t rr = d_to_json(ctx->responses[0]); + char* start = NULL; + if ((ctx->client->flags & FLAGS_KEEP_IN3) == 0 && (start = d_to_json(d_get(ctx->responses[0], K_IN3)).data) && start < rr.data + rr.len) { + while (*start != ',' && start > rr.data) start--; + char* res = _strdupn(rr.data, start - rr.data + 1); + res[start - rr.data] = '}'; + return res; } return _strdupn(rr.data, rr.len); } diff --git a/c/src/core/client/execute.c b/c/src/core/client/execute.c index 0e4c1354b..74ce1a624 100644 --- a/c/src/core/client/execute.c +++ b/c/src/core/client/execute.c @@ -107,7 +107,8 @@ NONULL static in3_ret_t pick_signers(in3_ctx_t* ctx, d_token_t* request) { return IN3_OK; // For nodeList request, we always ask for proof & atleast one signature - uint8_t total_sig_cnt = c->signature_count ? c->signature_count : auto_ask_sig(ctx) ? 1 : 0; + uint8_t total_sig_cnt = c->signature_count ? c->signature_count : auto_ask_sig(ctx) ? 1 + : 0; if (total_sig_cnt) { node_match_t* signer_nodes = NULL; diff --git a/c/src/core/client/nodelist.c b/c/src/core/client/nodelist.c index 05c642c53..ef8140f04 100644 --- a/c/src/core/client/nodelist.c +++ b/c/src/core/client/nodelist.c @@ -362,9 +362,9 @@ IN3_EXPORT_TEST bool in3_node_props_match(const in3_node_props_t np_config, cons } uint32_t in3_node_calculate_weight(in3_node_weight_t* n, uint32_t capa, uint64_t now) { - const uint32_t avg = (n->response_count > 4 && n->total_response_time) - ? (n->total_response_time / n->response_count) - : (10000 / (max(capa, 100) + 100)); + const uint32_t avg = (n->response_count > 4 && n->total_response_time) + ? (n->total_response_time / n->response_count) + : (10000 / (max(capa, 100) + 100)); const uint32_t blacklist_factor = ((now - n->blacklisted_until) < BLACKLISTWEIGHT) ? ((now - n->blacklisted_until) * 100 / (BLACKLISTWEIGHT)) : 100; diff --git a/c/src/core/util/data.c b/c/src/core/util/data.c index 67da844ad..c0016972f 100644 --- a/c/src/core/util/data.c +++ b/c/src/core/util/data.c @@ -96,7 +96,7 @@ d_key_t keyn(const char* c, const size_t len) { return kn->key; kn = kn->next; } - val = __keynames_len; + val = __keynames_len; #endif return val; } diff --git a/c/src/core/util/utils.c b/c/src/core/util/utils.c index 2f779e62c..bcfcc686d 100644 --- a/c/src/core/util/utils.c +++ b/c/src/core/util/utils.c @@ -61,7 +61,7 @@ static void srand_zephyr(unsigned int s) { static time_func in3_time_fn = time_zephyr; static rand_func in3_rand_fn = rand_zephyr; static srand_func in3_srand_fn = srand_zephyr; -#else /* __ZEPHYR__ */ +#else /* __ZEPHYR__ */ static uint64_t time_libc(void* t) { UNUSED_VAR(t); return time(t); @@ -127,38 +127,30 @@ const char* u64_to_str(uint64_t value, char* buffer, int buffer_len) { #endif int hex_to_bytes(const char* buf, int len, uint8_t* out, int outbuf_size) { - if (!buf && len) return -1; - if (len == -1) { - len = strlen(buf); - if (len >= 2 && *buf == '0' && buf[1] == 'x') { - buf += 2; - len -= 2; - } + if (!buf || len < -1) return len == 0 ? 0 : -1; + if (len == -1) len = strlen(buf); + if (buf[0] == '0' && buf[1] == 'x') { + buf += 2; + len -= 2; } - int i = len - 1; - int out_len = (len & 1) ? (len + 1) / 2 : len / 2; - int j = out_len - 1; - - if (j > outbuf_size) - return -1; /* Output buffer is smaller than need */ - - while (i >= 0) { - out[j] = hexchar_to_int(buf[i--]); - if (i >= 0) { - out[j--] |= hexchar_to_int(buf[i--]) << 4; - } + if (len == 0) return 0; + int bytes_len = (len + 1) / 2, i = 0, j = 0; + if (bytes_len > outbuf_size) return -1; + if (len & 1) { + out[0] = hexchar_to_int(buf[0]); + j = i = 1; } - return out_len; + for (; i < len; i += 2, ++j) + out[j] = (hexchar_to_int(buf[i]) << 4) | hexchar_to_int(buf[i + 1]); + + return bytes_len; } bytes_t* hex_to_new_bytes(const char* buf, int len) { - int bytes_len = (len & 1) ? (len + 1) / 2 : len / 2; - - uint8_t* b = _malloc(bytes_len); bytes_t* bytes = _malloc(sizeof(bytes_t)); - hex_to_bytes(buf, len, b, bytes_len); - bytes->data = b; - bytes->len = bytes_len; + bytes->len = (len + 1) / 2; + bytes->data = _malloc(bytes->len); + hex_to_bytes(buf, len, bytes->data, bytes->len); return bytes; } diff --git a/c/src/verifier/eth1/evm/evm.h b/c/src/verifier/eth1/evm/evm.h index fade2d40f..ecbe27eba 100644 --- a/c/src/verifier/eth1/evm/evm.h +++ b/c/src/verifier/eth1/evm/evm.h @@ -62,19 +62,19 @@ typedef enum evm_state { #define gas_options #endif -#define EVM_ERROR_EMPTY_STACK -20 /**< the no more elements on the stack */ -#define EVM_ERROR_INVALID_OPCODE -21 /**< the opcode is not supported */ -#define EVM_ERROR_BUFFER_TOO_SMALL -22 /**< reading data from a position, which is not initialized */ -#define EVM_ERROR_ILLEGAL_MEMORY_ACCESS -23 /**< the memory-offset does not exist */ -#define EVM_ERROR_INVALID_JUMPDEST -24 /**< the jump destination is not marked as valid destination */ -#define EVM_ERROR_INVALID_PUSH -25 /**< the push data is empy */ +#define EVM_ERROR_EMPTY_STACK -20 /**< the no more elements on the stack */ +#define EVM_ERROR_INVALID_OPCODE -21 /**< the opcode is not supported */ +#define EVM_ERROR_BUFFER_TOO_SMALL -22 /**< reading data from a position, which is not initialized */ +#define EVM_ERROR_ILLEGAL_MEMORY_ACCESS -23 /**< the memory-offset does not exist */ +#define EVM_ERROR_INVALID_JUMPDEST -24 /**< the jump destination is not marked as valid destination */ +#define EVM_ERROR_INVALID_PUSH -25 /**< the push data is empy */ #define EVM_ERROR_UNSUPPORTED_CALL_OPCODE -26 /**< error handling the call, usually because static-calls are not allowed to change state */ -#define EVM_ERROR_TIMEOUT -27 /**< the evm ran into a loop */ -#define EVM_ERROR_INVALID_ENV -28 /**< the enviroment could not deliver the data */ -#define EVM_ERROR_OUT_OF_GAS -29 /**< not enough gas to exewcute the opcode */ -#define EVM_ERROR_BALANCE_TOO_LOW -30 /**< not enough funds to transfer the requested value. */ -#define EVM_ERROR_STACK_LIMIT -31 /**< stack limit reached */ -#define EVM_ERROR_SUCCESS_CONSUME_GAS -32 /**< write success but consume all gas */ +#define EVM_ERROR_TIMEOUT -27 /**< the evm ran into a loop */ +#define EVM_ERROR_INVALID_ENV -28 /**< the enviroment could not deliver the data */ +#define EVM_ERROR_OUT_OF_GAS -29 /**< not enough gas to exewcute the opcode */ +#define EVM_ERROR_BALANCE_TOO_LOW -30 /**< not enough funds to transfer the requested value. */ +#define EVM_ERROR_STACK_LIMIT -31 /**< stack limit reached */ +#define EVM_ERROR_SUCCESS_CONSUME_GAS -32 /**< write success but consume all gas */ #define EVM_PROP_FRONTIER 1 #define EVM_PROP_EIP150 2 diff --git a/wasm/src/CMakeLists.txt b/wasm/src/CMakeLists.txt index 95478ddfc..390e2645c 100644 --- a/wasm/src/CMakeLists.txt +++ b/wasm/src/CMakeLists.txt @@ -32,18 +32,19 @@ # with this program. If not, see . ############################################################################### +set(EMC_PROPS "-Oz -s ALLOW_MEMORY_GROWTH=1 -s NODEJS_CATCH_REJECTION=0 -s EXPORT_NAME=in3w -s FILESYSTEM=0 -s 'EXTRA_EXPORTED_RUNTIME_METHODS=[\"ccall\", \"cwrap\"]'") + IF (ASMJS) set(WASM_EMBED true) set(CMAKE_EXECUTABLE_SUFFIX ".js") - set(EMC_PROPS "-O2 -s ALLOW_MEMORY_GROWTH=1 -s FINALIZE_ASM_JS=1 -s NODEJS_CATCH_REJECTION=0 -s SEPARATE_ASM=1 -s WASM=0 -s ASM_JS=1 -s EXPORT_NAME=in3w -s FILESYSTEM=0 -s 'EXTRA_EXPORTED_RUNTIME_METHODS=[\"ccall\", \"cwrap\"]'") + set(EMC_PROPS "${EMC_PROPS} -s FINALIZE_ASM_JS=1 -s SEPARATE_ASM=1 -s WASM=0 -s ASM_JS=1 ") else(ASMJS) - set(EMC_PROPS "-Oz -s ALLOW_MEMORY_GROWTH=1 -s NODEJS_CATCH_REJECTION=0 -s EXPORT_NAME=in3w -s WASM=1 -s FILESYSTEM=0 -s 'EXTRA_EXPORTED_RUNTIME_METHODS=[\"ccall\", \"cwrap\"]'") + set(EMC_PROPS "${EMC_PROPS} -s WASM=1") endif(ASMJS) IF (CMAKE_BUILD_TYPE MATCHES Debug) - set(EMC_PROPS "${EMC_PROPS} -g -s SAFE_HEAP=1 -s ASSERTIONS=1 -s STACK_OVERFLOW_CHECK=1 -s RUNTIME_LOGGING=1") -# set(EMC_PROPS "${EMC_PROPS} --source-map-base 'http://localhost/build/bin/' --emit-symbol-map -g -s ASSERTIONS=1 ") + set(EMC_PROPS "${EMC_PROPS} -g -s SAFE_HEAP=1 -s ASSERTIONS=1 -s STACK_OVERFLOW_CHECK=1 -s RUNTIME_LOGGING=1 ") ENDIF (CMAKE_BUILD_TYPE MATCHES Debug) if (WASM_EMBED) diff --git a/wasm/src/in3.js b/wasm/src/in3.js index 69a4eebf0..750df4edb 100644 --- a/wasm/src/in3.js +++ b/wasm/src/in3.js @@ -352,7 +352,7 @@ function url_queue(req) { try { blacklist = r.error || !!JSON.parse(r.response)[0].error } - catch { + catch (x) { blacklist = true } if (blacklist) in3w.ccall('in3_blacklist', 'void', ['number', 'string'], [ptr, r.url])