Fix deadlock in Table implementation

This commit is contained in:
Mark McCaskey
2020-06-29 12:06:03 -07:00
parent de0c548653
commit 4711abdebb
2 changed files with 5 additions and 4 deletions

View File

@@ -4,7 +4,6 @@ use crate::store::Store;
use crate::types::{Val, ValFuncRef};
use crate::RuntimeError;
use crate::TableType;
use std::sync::Arc;
use wasmer_runtime::{Export, ExportTable, Table as RuntimeTable, VMCallerCheckedAnyfunc};
/// The `Table` struct is an array-like structure representing a WebAssembly Table,

View File

@@ -1,7 +1,7 @@
use crate::ValType;
use std::borrow::{Borrow, BorrowMut};
use std::cell::UnsafeCell;
use std::convert::{TryFrom, TryInto};
use std::convert::TryFrom;
use std::ptr::NonNull;
use std::sync::Mutex;
use wasmer_runtime::{
@@ -64,8 +64,10 @@ impl Table for LinearTable {
/// Returns the number of allocated elements.
fn size(&self) -> u32 {
let vec_guard = self.vec.lock().unwrap();
vec_guard.borrow().len().try_into().unwrap()
unsafe {
let ptr = self.vm_table_definition.get();
(*ptr).current_elements
}
}
/// Grow table by the specified amount of elements.