Stream: git-wasmtime

Topic: wasmtime / Issue #2807 cranelift-jit reapplies memory pro...


view this post on Zulip Wasmtime GitHub notifications bot (Apr 06 2021 at 04:42):

mchesser opened Issue #2807:

After calling JITModule::finalize_definitions, allocations for code/data are mprotected to be executable/readonly:

https://github.com/bytecodealliance/wasmtime/blob/6b77786a6e758e91da9484a1c80b6fa5f88e1b3d/cranelift/jit/src/memory.rs#L175-L231

However, self.executable is never updated so mprotect is invoked for _all_ allocations, even ones that have the correct permissions. This makes future finalize_definitions slower.

I think it can be fixed by just adding:

self.executable = self.allocations.len();

At the end of each of the protection functions.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 06 2021 at 04:45):

mchesser edited Issue #2807:

After calling JITModule::finalize_definitions, allocations for code/data are mprotected to be executable/readonly:

https://github.com/bytecodealliance/wasmtime/blob/6b77786a6e758e91da9484a1c80b6fa5f88e1b3d/cranelift/jit/src/memory.rs#L175-L231

However, self.executable is never updated so mprotect is invoked for _all_ allocations, even ones that have the correct permissions. This makes future finalize_definitions slower.

I think it can be fixed by just adding:

self.executable = self.allocations.len();

At the end of each of the protection functions, and fixing any clearing code.


Last updated: Dec 23 2024 at 13:07 UTC