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::types::{Val, ValFuncRef};
use crate::RuntimeError; use crate::RuntimeError;
use crate::TableType; use crate::TableType;
use std::sync::Arc;
use wasmer_runtime::{Export, ExportTable, Table as RuntimeTable, VMCallerCheckedAnyfunc}; use wasmer_runtime::{Export, ExportTable, Table as RuntimeTable, VMCallerCheckedAnyfunc};
/// The `Table` struct is an array-like structure representing a WebAssembly Table, /// The `Table` struct is an array-like structure representing a WebAssembly Table,

View File

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