MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / checkNullTableEntry

Function checkNullTableEntry

test/executor/ExecutorRegressionTest.cpp:59–78  ·  view source on GitHub ↗

After instantiation, read the exported table "t" at index 0 and verify the null reference has been normalized to an abstract heap type. This catches the root cause of #4757 without executing wasm that would segfault if the fix is absent.

Source from the content-addressed store, hash-verified

57/// the root cause of #4757 without executing wasm that would segfault if the
58/// fix is absent.
59bool checkNullTableEntry(VM::VM &VMInst) {
60 const auto *ModInst = VMInst.getActiveModule();
61 if (!ModInst) {
62 return false;
63 }
64 auto *TabInst = ModInst->findTableExports("t");
65 if (!TabInst) {
66 return false;
67 }
68 auto RefRes = TabInst->getRefAddr(0);
69 if (!RefRes) {
70 return false;
71 }
72 auto Ref = *RefRes;
73 EXPECT_TRUE(Ref.isNull());
74 EXPECT_TRUE(Ref.getType().isAbsHeapType())
75 << "Null reference in concrete-typed table must be normalized to an "
76 "abstract heap type (issue #4757)";
77 return Ref.isNull() && Ref.getType().isAbsHeapType();
78}
79
80// clang-format off
81/// Binary Wasm module with functions testing ref.test on externalized refs.

Callers 1

TESTFunction · 0.85

Calls 6

getActiveModuleMethod · 0.80
findTableExportsMethod · 0.80
getRefAddrMethod · 0.80
isNullMethod · 0.80
isAbsHeapTypeMethod · 0.80
getTypeMethod · 0.45

Tested by

no test coverage detected