Fix data/elem drop (#2747)
Currently, `data.drop` instruction is implemented by directly modifying the underlying module. It breaks use cases where you have multiple instances sharing a single loaded module. `elem.drop` has the same problem too. This PR fixes the issue by keeping track of which data/elem segments have been dropped by using bitmaps for each module instances separately, and add a sample to demonstrate the issue and make the CI run it. Also add a missing check of dropped elements to the fast-jit `table.init`. Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2735 Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2772
This commit is contained in:
22
samples/shared-module/wasm-apps/testapp.wat
Normal file
22
samples/shared-module/wasm-apps/testapp.wat
Normal file
@ -0,0 +1,22 @@
|
||||
;; Copyright (C) 2023 Midokura Japan KK. All rights reserved.
|
||||
;; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
(module
|
||||
(func (export "test_data_drop") (result i32)
|
||||
(memory.init 0 (i32.const 0) (i32.const 0) (i32.const 4))
|
||||
data.drop 0
|
||||
(i32.load (i32.const 0))
|
||||
)
|
||||
(func (export "test_elem_drop") (result i32)
|
||||
(table.init 0 (i32.const 0) (i32.const 0) (i32.const 4))
|
||||
elem.drop 0
|
||||
i32.const 3
|
||||
table.get 0
|
||||
ref.is_null
|
||||
)
|
||||
(func $f)
|
||||
(memory 1 1)
|
||||
(table 4 4 funcref)
|
||||
(data "abcd")
|
||||
(elem func $f $f $f $f)
|
||||
)
|
||||
Reference in New Issue
Block a user