More code review changes.
* Add more overflow checks in table/memory initialization. * Comment for `with_allocation_strategy` to explain ignored `Config` options. * Fix Wasmtime `Table` to not panic for type mismatches in `fill`/`copy`. * Add tests for that fix.
This commit is contained in:
@@ -826,6 +826,12 @@ impl Config {
|
||||
}
|
||||
|
||||
/// Sets the instance allocation strategy to use.
|
||||
///
|
||||
/// When using the pooling instance allocation strategy, all linear memories will be created as "static".
|
||||
///
|
||||
/// This means the [`Config::static_memory_maximum_size`] and [`Config::static_memory_guard_size`] options
|
||||
/// will be ignored in favor of [`InstanceLimits::memory_reservation_size`] when the pooling instance
|
||||
/// allocation strategy is used.
|
||||
pub fn with_allocation_strategy(
|
||||
&mut self,
|
||||
strategy: InstanceAllocationStrategy,
|
||||
|
||||
@@ -547,10 +547,13 @@ impl Table {
|
||||
bail!("cross-`Store` table copies are not supported");
|
||||
}
|
||||
|
||||
if dst_table.ty() != src_table.ty() {
|
||||
bail!("tables do not have the same element type");
|
||||
}
|
||||
|
||||
// NB: We must use the `dst_table`'s `wasmtime_handle` for the
|
||||
// `dst_table_index` and vice versa for `src_table` since each table can
|
||||
// come from different modules.
|
||||
|
||||
let dst_table_index = dst_table.wasmtime_table_index();
|
||||
let dst_table_index = dst_table.instance.get_defined_table(dst_table_index);
|
||||
|
||||
@@ -579,6 +582,11 @@ impl Table {
|
||||
bail!("cross-`Store` table fills are not supported");
|
||||
}
|
||||
|
||||
// Ensure the fill value is the correct type
|
||||
if self.ty().element() != &val.ty() {
|
||||
bail!("mismatched element fill type");
|
||||
}
|
||||
|
||||
let table_index = self.wasmtime_table_index();
|
||||
self.instance
|
||||
.handle
|
||||
|
||||
@@ -27,6 +27,8 @@ pub(crate) fn create_handle(
|
||||
|
||||
unsafe {
|
||||
// Use the default allocator when creating handles associated with host objects
|
||||
// The configured instance allocator should only be used when creating module instances
|
||||
// as we don't want host objects to count towards instance limits.
|
||||
let handle = store
|
||||
.engine()
|
||||
.config()
|
||||
|
||||
Reference in New Issue
Block a user