From 8bf791e659dd7386c5cccc6028672a25f16eb29d Mon Sep 17 00:00:00 2001 From: victoryang00 Date: Thu, 30 May 2024 19:52:38 +0800 Subject: [PATCH] Merge branch 'dev/checkpoint_and_restore' into main --- ATTRIBUTIONS.md | 7 +- core/iwasm/aot/aot_runtime.c | 3 +- core/iwasm/common/wasm_runtime_common.h | 6 + core/iwasm/compilation/aot_compiler.c | 4 - core/iwasm/include/wasm_export.h | 40 +--- core/iwasm/interpreter/wasm_interp_classic.c | 2 +- core/iwasm/interpreter/wasm_mini_loader.c | 2 +- .../ckpt-restore/LICENSE_YALANTINGLIBS | 201 ++++++++++++++++++ core/iwasm/libraries/ckpt-restore/wamr.cpp | 14 +- .../libraries/ckpt-restore/wamr_exec_env.cpp | 30 ++- .../ckpt-restore/wamr_interp_frame.cpp | 6 +- .../libraries/libc-wasi/libc_wasi_wrapper.c | 2 +- 12 files changed, 256 insertions(+), 61 deletions(-) create mode 100644 core/iwasm/libraries/ckpt-restore/LICENSE_YALANTINGLIBS diff --git a/ATTRIBUTIONS.md b/ATTRIBUTIONS.md index 2c83d66748..f9ce380670 100644 --- a/ATTRIBUTIONS.md +++ b/ATTRIBUTIONS.md @@ -18,7 +18,7 @@ WAMR project reused some components from other open source project: - **NuttX ELF headers**: used in core/iwasm/aot/debug/elf_parser.c - **Dhrystone**: for the test benchmakr dhrystone -The WAMR fast interpreter is a clean room development. We would acknowledge the inspirations by [WASM3](https://github.com/wasm3/wasm3) open source project for the approach of pre-calculated oprand stack location. +The WAMR fast interpreter is a clean room development. We would acknowledge the inspirations by [WASM3](https://github.com/wasm3/wasm3) open source project for the approach of pre-calculated operand stack location. | third party components | version number | latest release | vendor pages | CVE details | | --- | --- | --- | --- | --- | @@ -37,6 +37,7 @@ The WAMR fast interpreter is a clean room development. We would acknowledge the | zydis | unspecified | e14a07895136182a5b53e181eec3b1c6e0b434de | https://github.com/zyantific/zydis | | | NuttX ELF headers | 72313301e23f9c2de969fb64b9a0f67bb4c284df | 10.3.0 | https://github.com/apache/incubator-nuttx | | | Dhrystone | 2.1 | 2.1 | https://fossies.org/linux/privat/old/ | | +| yalantinglibs | v0.3.2 | v0.3.2 | https://github.com/alibaba/yalantinglibs | | ## Licenses @@ -103,3 +104,7 @@ The WAMR fast interpreter is a clean room development. We would acknowledge the ### Dhrystone [LICENSE](./tests/benchmarks/dhrystone/LICENSE) + +### yalantinglibs + +[LICENSE](./core/iwasm/libraries/ckpt-restore/LICENSE_YALANTINGLIBS) \ No newline at end of file diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 4258592a72..8ed36e9dec 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -1055,7 +1055,8 @@ memories_instantiate(AOTModuleInstance *module_inst, AOTModuleInstance *parent, #if WASM_ENABLE_SHARED_MEMORY != 0 /* Currently we have only one memory instance */ - bool is_shared_memory = module->memories[0].memory_flags & 0x02 ? true : false; + bool is_shared_memory = + module->memories[0].memory_flags & 0x02 ? true : false; if (is_shared_memory && parent != NULL) { /* Ignore setting memory init data if the memory has been initialized */ return true; diff --git a/core/iwasm/common/wasm_runtime_common.h b/core/iwasm/common/wasm_runtime_common.h index 0a52b7ef11..be75bf8c5f 100644 --- a/core/iwasm/common/wasm_runtime_common.h +++ b/core/iwasm/common/wasm_runtime_common.h @@ -1216,6 +1216,12 @@ wasm_runtime_checkpoint(wasm_module_inst_t module_inst, char *file); bool wasm_runtime_restore(wasm_module_inst_t module_inst, char *file, char *file1); #endif +WASM_RUNTIME_API_EXTERN bool +wasm_runtime_detect_native_stack_overflow(WASMExecEnv *exec_env); + +WASM_RUNTIME_API_EXTERN bool +wasm_runtime_detect_native_stack_overflow_size(WASMExecEnv *exec_env, + uint32 requested_size); #if WASM_ENABLE_LINUX_PERF != 0 bool diff --git a/core/iwasm/compilation/aot_compiler.c b/core/iwasm/compilation/aot_compiler.c index 5fb8c7d6f1..b825e94dcb 100644 --- a/core/iwasm/compilation/aot_compiler.c +++ b/core/iwasm/compilation/aot_compiler.c @@ -487,10 +487,6 @@ fake_aot_gen_commit_value(AOTCompFrame *frame, bool reset_dirty_bit, case VALUE_TYPE_FUNCREF: case VALUE_TYPE_EXTERNREF: break; - break; - - break; - case VALUE_TYPE_I64: if (reset_dirty_bit) ((*p) + 1)->dirty = 0; diff --git a/core/iwasm/include/wasm_export.h b/core/iwasm/include/wasm_export.h index 9941f8b00f..13bf8f80a3 100644 --- a/core/iwasm/include/wasm_export.h +++ b/core/iwasm/include/wasm_export.h @@ -611,7 +611,6 @@ wasm_runtime_set_wasi_ns_lookup_pool(wasm_module_t module, */ WASM_RUNTIME_API_EXTERN wasm_module_inst_t wasm_runtime_instantiate(const wasm_module_t module, -<<<<<<< HEAD uint32_t default_stack_size, uint32_t host_managed_heap_size, char *error_buf, uint32_t error_buf_size); @@ -626,14 +625,6 @@ WASM_RUNTIME_API_EXTERN wasm_module_inst_t wasm_runtime_instantiate_ex(const wasm_module_t module, const InstantiationArgs *args, char *error_buf, uint32_t error_buf_size); -||||||| parent of d8948a72 (Update version number to 2.0.0 and update release notes (#3327)) - uint32_t default_stack_size, uint32_t host_managed_heap_size, - char *error_buf, uint32_t error_buf_size); -======= - uint32_t default_stack_size, - uint32_t host_managed_heap_size, char *error_buf, - uint32_t error_buf_size); ->>>>>>> d8948a72 (Update version number to 2.0.0 and update release notes (#3327)) /** * Instantiate a WASM module, with specified instantiation arguments @@ -649,12 +640,13 @@ wasm_runtime_instantiate_ex(const wasm_module_t module, /** * Instantiate a WASM module, with specified instantiation arguments * - * Same as wasm_runtime_instantiate, but it also allows overwriting maximum memory + * Same as wasm_runtime_instantiate, but it also allows overwriting maximum + * memory */ WASM_RUNTIME_API_EXTERN wasm_module_inst_t wasm_runtime_instantiate_ex(const wasm_module_t module, - const InstantiationArgs *args, - char *error_buf, uint32_t error_buf_size); + const InstantiationArgs *args, char *error_buf, + uint32_t error_buf_size); /** * Set the running mode of a WASM module instance, override the @@ -1531,16 +1523,8 @@ WASM_RUNTIME_API_EXTERN double wasm_runtime_sum_wasm_exec_time(wasm_module_inst_t module_inst); /** -<<<<<<< HEAD * Return execution time in ms of a given wasm function with * func_name. If the function is not found, return 0. -||||||| parent of d8948a72 (Update version number to 2.0.0 and update release notes (#3327)) - * Return execution time in ms of a given wasm funciton with -* func_name. If the function is not found, return 0. -======= - * Return execution time in ms of a given wasm funciton with - * func_name. If the function is not found, return 0. ->>>>>>> d8948a72 (Update version number to 2.0.0 and update release notes (#3327)) * * @param module_inst the WASM module instance to profile * @param func_name could be an export name or a name in the @@ -1762,16 +1746,8 @@ wasm_runtime_is_import_func_linked(const char *module_name, const char *func_name); /** -<<<<<<< HEAD * Check whether an import global `(import * (global ...))` is linked or not with runtime registered native globals -||||||| parent of d8948a72 (Update version number to 2.0.0 and update release notes (#3327)) - * Check whether an import global `(import (global ...))` - * is linked or not with runtime registered natvie globals -======= - * Check whether an import global `(import - * (global ...))` is linked or not with runtime registered natvie globals ->>>>>>> d8948a72 (Update version number to 2.0.0 and update release notes (#3327)) */ WASM_RUNTIME_API_EXTERN bool wasm_runtime_is_import_global_linked(const char *module_name, @@ -1980,7 +1956,7 @@ wasm_runtime_is_underlying_binary_freeable(const wasm_module_t module); /* * wasm_runtime_checkpoint/wasm_runtime_restore * - * These APIs are intended to be used by the host to register the current + * These APIs are intended to be used by the host to register the current * state of the WASM module instance to a file and restore the state from * file * eg. @@ -1993,11 +1969,9 @@ wasm_runtime_is_underlying_binary_freeable(const wasm_module_t module); * } */ WASM_RUNTIME_API_EXTERN bool -wasm_runtime_checkpoint(wasm_module_inst_t module_inst, - char *file); +wasm_runtime_checkpoint(wasm_module_inst_t module_inst, char *file); WASM_RUNTIME_API_EXTERN bool -wasm_runtime_restore(wasm_module_inst_t module_inst, - char *file, char *file1); +wasm_runtime_restore(wasm_module_inst_t module_inst, char *file, char *file1); #endif WASM_RUNTIME_API_EXTERN bool diff --git a/core/iwasm/interpreter/wasm_interp_classic.c b/core/iwasm/interpreter/wasm_interp_classic.c index 18de5f1fda..b573975eef 100644 --- a/core/iwasm/interpreter/wasm_interp_classic.c +++ b/core/iwasm/interpreter/wasm_interp_classic.c @@ -1504,7 +1504,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, uint8 value_type; #if WASM_ENABLE_CHECKPOINT_RESTORE != 0 if (exec_env->is_restore) { - // WASMFunction *cur_wasm_func = cur_func->u.func; + WASMFunction *cur_wasm_func = cur_func->u.func; frame = exec_env->cur_frame; UPDATE_ALL_FROM_FRAME(); frame_ip_end = wasm_get_func_code_end(cur_func); diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index 0144e3b358..bb830716b0 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -4269,7 +4269,7 @@ wasm_loader_pop_frame_ref(WASMLoaderContext *ctx, uint8 type, char *error_buf, ctx->frame_ref--; ctx->stack_cell_num--; - if (is_32bit_type(type) || *ctx->frame_ref == VALUE_TYPE_ANY) + if (is_32bit_type(type)) return true; ctx->frame_ref--; diff --git a/core/iwasm/libraries/ckpt-restore/LICENSE_YALANTINGLIBS b/core/iwasm/libraries/ckpt-restore/LICENSE_YALANTINGLIBS new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/core/iwasm/libraries/ckpt-restore/LICENSE_YALANTINGLIBS @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/core/iwasm/libraries/ckpt-restore/wamr.cpp b/core/iwasm/libraries/ckpt-restore/wamr.cpp index 37bc86d33c..47f236d795 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr.cpp +++ b/core/iwasm/libraries/ckpt-restore/wamr.cpp @@ -50,7 +50,8 @@ class CountingSemaphore public: explicit CountingSemaphore(int count) : count_(count) - {} + { + } void acquire() { @@ -258,9 +259,8 @@ WAMRInstance::~WAMRInstance() void WAMRInstance::find_func(const char *name) { -#if WASM_ENABLE_CUSTUM_NAME_SECTION != 0 if (!(func = wasm_runtime_lookup_function(module_inst, name))) { - LOG_DEBUG("The wasi\"%s\"function is not found.", name); + LOG_DEBUG("The wasi \"%s\" function is not found.", name); auto target_module = get_module_instance()->e; for (int i = 0; i < target_module->function_count; i++) { auto cur_func = &target_module->functions[i]; @@ -283,10 +283,6 @@ WAMRInstance::find_func(const char *name) } } } -#else - LOG_ERROR("Not supported without custom name section"); - exit(-1); -#endif } int WAMRInstance::invoke_main() @@ -303,7 +299,7 @@ WAMRInstance::invoke_init_c() { auto name1 = "__wasm_call_ctors"; if (!(func = wasm_runtime_lookup_function(module_inst, name1))) { - LOG_DEBUG("The wasi ", name1, " function is not found."); + LOG_DEBUG("The wasi %d function is not found.", name1); } else { wasm_runtime_call_wasm(exec_env, func, 0, nullptr); @@ -662,7 +658,7 @@ WAMRInstance::recover(std::vector> *e_) set_wasi_args(execEnv.front()->module_inst.wasi_ctx); instantiate(); this->time = std::chrono::high_resolution_clock::now(); - invoke_init_c(); + // invoke_init_c(); restore(execEnv.front(), cur_env); if (tid_start_arg_map.find(execEnv.back()->cur_count) diff --git a/core/iwasm/libraries/ckpt-restore/wamr_exec_env.cpp b/core/iwasm/libraries/ckpt-restore/wamr_exec_env.cpp index d31f21e35e..648158a449 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr_exec_env.cpp +++ b/core/iwasm/libraries/ckpt-restore/wamr_exec_env.cpp @@ -78,21 +78,26 @@ WAMRExecEnv::restore_impl(WASMExecEnv *env) auto module_inst = (WASMModuleInstance *)env->module_inst; auto get_function = [&](size_t function_index) { if (function_index < module_inst->e->function_count) { - LOG_DEBUG("function_index {} restored", function_index); + LOG_DEBUG("function_index %d restored", function_index); auto function = &module_inst->e->functions[function_index]; if (function->is_import_func) { - LOG_DEBUG("function_index {} is_import_func", + LOG_DEBUG("function_index %d is_import_func", function_index); exit(-1); } return function; } else { - LOG_DEBUG("function_index {} invalid", function_index); + LOG_DEBUG("function_index %d invalid", function_index); exit(-1); }; }; + auto get_function_name = [&](std::string function_name) { + wamr->find_func(function_name.c_str()); + return ((WASMFunctionInstance *)wamr->func); + }; + auto ALLOC_FRAME = [&](WASMExecEnv *exec_env, uint32 size, WASMInterpFrame *prev_frame) { auto frame = (WASMInterpFrame *)wasm_exec_env_alloc_wasm_frame( @@ -108,7 +113,16 @@ WAMRExecEnv::restore_impl(WASMExecEnv *env) }; std::reverse(frames.begin(), frames.end()); - auto function = get_function(frames.at(0)->function_index); + WASMFunctionInstance *function; + if (frames.at(0)->function_name.empty()) { + frames.erase(frames.begin()); + } + if (frames.at(0)->function_index == 0) { + function = get_function_name(frames.at(0)->function_name); + } + else { + function = get_function(frames.at(0)->function_index); + } unsigned all_cell_num = function->ret_cell_num > 2 ? function->ret_cell_num : 2; unsigned frame_size = wasm_interp_interp_frame_size(all_cell_num); @@ -118,7 +132,13 @@ WAMRExecEnv::restore_impl(WASMExecEnv *env) frame->ip = nullptr; prev_frame = frame; for (const auto &dump_frame : frames) { - auto cur_func = get_function(dump_frame->function_index); + WASMFunctionInstance *cur_func; + if (dump_frame->function_index > 0) { + cur_func = get_function(dump_frame->function_index); + } + else { + cur_func = get_function_name(dump_frame->function_name); + } auto cur_wasm_func = cur_func->u.func; all_cell_num = cur_func->param_cell_num + cur_func->local_cell_num + cur_wasm_func->max_stack_cell_num diff --git a/core/iwasm/libraries/ckpt-restore/wamr_interp_frame.cpp b/core/iwasm/libraries/ckpt-restore/wamr_interp_frame.cpp index 2461d154ba..9d4b8797c5 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr_interp_frame.cpp +++ b/core/iwasm/libraries/ckpt-restore/wamr_interp_frame.cpp @@ -34,12 +34,10 @@ WAMRInterpFrame::dump_impl(WASMInterpFrame *env) ->wasm_stack.bottom); // offset to the wasm_stack_top } #endif -#if WASM_ENABLE_CUSTOM_NAME_SECTION != 0 if (env->function->u.func->field_name) function_name = env->function->u.func->field_name; else function_name = env->function->u.func_import->field_name; -#endif } } std::vector> @@ -49,7 +47,7 @@ void WAMRInterpFrame::restore_impl(WASMInterpFrame *env) { auto module_inst = (WASMModuleInstance *)wamr->get_exec_env()->module_inst; - if (0 <= function_index + if (0 < function_index && function_index < module_inst->e->function_count) { // LOGV(INFO) << fmt::format("function_index {} restored", // function_index); @@ -59,7 +57,6 @@ WAMRInterpFrame::restore_impl(WASMInterpFrame *env) exit(-1); } } -#if WASM_ENABLE_CUSTOM_NAME_SECTION != 0 else { auto target_module = wamr->get_module_instance()->e; for (uint32 i = 0; i < target_module->function_count; i++) { @@ -82,7 +79,6 @@ WAMRInterpFrame::restore_impl(WASMInterpFrame *env) } } } -#endif wamr->set_func(env->function->u.func); auto cur_func = env->function; WASMFunction *cur_wasm_func = cur_func->u.func; diff --git a/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c b/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c index 70e1afa5f9..0c5587e311 100644 --- a/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c +++ b/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c @@ -2595,7 +2595,7 @@ wasi_sock_recv(wasm_exec_env_t exec_env, wasi_fd_t sock, iovec_app_t *ri_data, ro_flags); set_tcp(); #endif - if (!validate_native_addr(ro_flags, (uint32)sizeof(wasi_roflags_t))) + if (!validate_native_addr(ro_flags, (uint64)sizeof(wasi_roflags_t))) return __WASI_EINVAL; error = wasi_sock_recv_from(exec_env, sock, ri_data, ri_data_len, ri_flags,