Skip to content

Commit ac5eedd

Browse files
committed
fix
1 parent e84664f commit ac5eedd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/wasm/wasm-type.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ Type::Type(const Array& array) {
189189

190190
bool Type::isMulti() const {
191191
if (id > _last_value_type) {
192+
std::lock_guard<std::mutex> lock(mutex);
192193
auto it = complexLookup.find(id);
193194
if (it != complexLookup.end()) {
194195
return it->second.kind == TypeDef::TupleKind;
@@ -199,6 +200,7 @@ bool Type::isMulti() const {
199200

200201
bool Type::isRef() const {
201202
if (id > _last_value_type) {
203+
std::lock_guard<std::mutex> lock(mutex);
202204
auto it = complexLookup.find(id);
203205
if (it != complexLookup.end()) {
204206
switch (it->second.kind) {
@@ -217,6 +219,7 @@ bool Type::isRef() const {
217219
size_t Type::size() const { return expand().size(); }
218220

219221
const Tuple& Type::expand() const {
222+
std::lock_guard<std::mutex> lock(mutex);
220223
auto it = complexLookup.find(id);
221224
if (it != complexLookup.end()) {
222225
auto& typeDef = it->second;
@@ -475,8 +478,9 @@ std::ostream& operator<<(std::ostream& os, Type type) {
475478
break;
476479
default: {
477480
assert(id > Type::_last_value_type);
481+
std::lock_guard<std::mutex> lock(mutex);
478482
auto it = complexLookup.find(id);
479-
if (it != complexLookup.end()) {
483+
if (it == complexLookup.end()) {
480484
auto& typeDef = it->second;
481485
switch (typeDef.kind) {
482486
case TypeDef::TupleKind: {

0 commit comments

Comments
 (0)