From 5f8dc7f14f76300668c6c1a922d8c4133da7e908 Mon Sep 17 00:00:00 2001 From: Lin Huang Date: Wed, 6 Jul 2022 17:59:48 -0400 Subject: [PATCH 1/2] Fixing compile warnings in eos-vm-oc's memory.hpp, executor.cpp, and memory.cpp --- .../include/eosio/chain/webassembly/eos-vm-oc/memory.hpp | 4 +++- libraries/chain/webassembly/runtimes/eos-vm-oc/executor.cpp | 2 +- libraries/chain/webassembly/runtimes/eos-vm-oc/memory.cpp | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libraries/chain/include/eosio/chain/webassembly/eos-vm-oc/memory.hpp b/libraries/chain/include/eosio/chain/webassembly/eos-vm-oc/memory.hpp index d329b830c0..c20ef9e2eb 100644 --- a/libraries/chain/include/eosio/chain/webassembly/eos-vm-oc/memory.hpp +++ b/libraries/chain/include/eosio/chain/webassembly/eos-vm-oc/memory.hpp @@ -50,7 +50,9 @@ class memory { // The maximum amount of data that PIC code can include in the prologue static constexpr uintptr_t max_prologue_size = mutable_global_size + table_size; - static_assert(-cb_offset == EOS_VM_OC_CONTROL_BLOCK_OFFSET, "EOS VM OC control block offset has slid out of place somehow"); + // Changed from -cb_offset == EOS_VM_OC_CONTROL_BLOCK_OFFSET to get around + // of compile warning about comparing integers of different signedness + static_assert(EOS_VM_OC_CONTROL_BLOCK_OFFSET + cb_offset == 0, "EEOS VM OC control block offset has slid out of place somehow"); static_assert(stride == EOS_VM_OC_MEMORY_STRIDE, "EOS VM OC memory stride has slid out of place somehow"); private: diff --git a/libraries/chain/webassembly/runtimes/eos-vm-oc/executor.cpp b/libraries/chain/webassembly/runtimes/eos-vm-oc/executor.cpp index ca32f8cd0e..8140d1a197 100644 --- a/libraries/chain/webassembly/runtimes/eos-vm-oc/executor.cpp +++ b/libraries/chain/webassembly/runtimes/eos-vm-oc/executor.cpp @@ -223,7 +223,7 @@ void executor::execute(const code_descriptor& code, memory& mem, apply_context& cb->bounce_buffers->clear(); tt.set_expiration_callback(nullptr, nullptr); - uint64_t base_pages = mem.size_of_memory_slice_mapping()/memory::stride - 1; + int64_t base_pages = mem.size_of_memory_slice_mapping()/memory::stride - 1; if(cb->current_linear_memory_pages > base_pages) { mprotect(mem.full_page_memory_base() + base_pages * eosio::chain::wasm_constraints::wasm_page_size, (cb->current_linear_memory_pages - base_pages) * eosio::chain::wasm_constraints::wasm_page_size, PROT_NONE); diff --git a/libraries/chain/webassembly/runtimes/eos-vm-oc/memory.cpp b/libraries/chain/webassembly/runtimes/eos-vm-oc/memory.cpp index 293ed229d8..db17b9d5d7 100644 --- a/libraries/chain/webassembly/runtimes/eos-vm-oc/memory.cpp +++ b/libraries/chain/webassembly/runtimes/eos-vm-oc/memory.cpp @@ -25,7 +25,7 @@ memory::memory(uint64_t max_pages) { FC_ASSERT(mapbase != MAP_FAILED, "Failed to mmap memory"); uint8_t* next_slice = mapbase; - uint8_t* last; + uint8_t* last = nullptr; for(unsigned int p = 0; p < number_slices; ++p) { last = (uint8_t*)mmap(next_slice, memory_prologue_size+64u*1024u*p, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, fd, 0); @@ -33,6 +33,7 @@ memory::memory(uint64_t max_pages) { next_slice += total_memory_per_slice; } + FC_ASSERT(last != nullptr, "expected last not nullptr"); zeropage_base = mapbase + memory_prologue_size; fullpage_base = last + memory_prologue_size; From 4e24b850366228e7f29d527fcf801a345c30f26c Mon Sep 17 00:00:00 2001 From: Lin Huang Date: Wed, 6 Jul 2022 19:38:37 -0400 Subject: [PATCH 2/2] Fix a typo introduced to an assert string by accident --- .../chain/include/eosio/chain/webassembly/eos-vm-oc/memory.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chain/include/eosio/chain/webassembly/eos-vm-oc/memory.hpp b/libraries/chain/include/eosio/chain/webassembly/eos-vm-oc/memory.hpp index c20ef9e2eb..60b2619ca1 100644 --- a/libraries/chain/include/eosio/chain/webassembly/eos-vm-oc/memory.hpp +++ b/libraries/chain/include/eosio/chain/webassembly/eos-vm-oc/memory.hpp @@ -52,7 +52,7 @@ class memory { // Changed from -cb_offset == EOS_VM_OC_CONTROL_BLOCK_OFFSET to get around // of compile warning about comparing integers of different signedness - static_assert(EOS_VM_OC_CONTROL_BLOCK_OFFSET + cb_offset == 0, "EEOS VM OC control block offset has slid out of place somehow"); + static_assert(EOS_VM_OC_CONTROL_BLOCK_OFFSET + cb_offset == 0, "EOS VM OC control block offset has slid out of place somehow"); static_assert(stride == EOS_VM_OC_MEMORY_STRIDE, "EOS VM OC memory stride has slid out of place somehow"); private: