Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.2] Fix compile warnings in eos-vm-oc's memory.hpp, executor.cpp, and memory.cpp #615

Merged
merged 3 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, "EEOS VM OC control block offset has slid out of place somehow");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo introduced in to string here (EEOS)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @spoonincode for your sharp eyes! Sorry for that.

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