Skip to content

Commit

Permalink
wasm: directly handle recycling of invalidated instance
Browse files Browse the repository at this point in the history
An instance may be invalidated before we try to recycle it.
We perform this by setting its value to a nullopt.
This patch adds a check for it when calculating its size.
This behavior didn't cause issues before because the catch
clause below caught errors caused by calling value() on
a nullopt, even though it was intended for errors from
get_instance_size.

Signed-off-by: Wojciech Mitros <wojciech.mitros@scylladb.com>

Closes #11500
  • Loading branch information
wmitros authored and avikivity committed Sep 8, 2022
1 parent f435276 commit 7effd4c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lang/wasm_instance_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ void instance_cache::recycle(instance_cache::value_type val) noexcept {
val->mutex.unlock();
size_t size;
try {
if (!val->instance) {
return;
}
size = get_instance_size(val->instance.value());
if (size > 1 * MB) {
val->instance = std::nullopt;
Expand Down

0 comments on commit 7effd4c

Please sign in to comment.