mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-06 20:58:28 +00:00
Fix deadlock in Table implementation
This commit is contained in:
1
lib/api/src/externals/table.rs
vendored
1
lib/api/src/externals/table.rs
vendored
@@ -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,
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user