Skip to content

Commit

Permalink
Merge pull request #615 from eosnetworkfoundation/fix_memory_h_warning
Browse files Browse the repository at this point in the history
[3.2] Fix compile warnings in eos-vm-oc's memory.hpp, executor.cpp, and memory.cpp
  • Loading branch information
linh2931 authored Jul 7, 2022
2 parents 8001c3a + f9ef859 commit d6b55a9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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, "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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion libraries/chain/webassembly/runtimes/eos-vm-oc/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ 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);
FC_ASSERT(last != MAP_FAILED, "Failed to mmap memory");
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;

Expand Down

0 comments on commit d6b55a9

Please sign in to comment.