Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/binary-reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3044,7 +3044,8 @@ Result BinaryReader::ReadModule(const ReadModuleOptions& options) {
"function signature count != function body count");
// This is checked in ReadDataSection, but it must be checked at the end too,
// in case the data section was omitted.
ERROR_IF(num_data_segments_ == 0 && data_count_ != kInvalidIndex,
ERROR_IF(num_data_segments_ == 0 && data_count_ != kInvalidIndex &&
data_count_ != 0,
"Data section missing but DataCount non-zero");
CALLBACK0(EndModule);

Expand Down
5 changes: 4 additions & 1 deletion src/error-formatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ std::string FormatError(const Error& error,
result += '\n';
result += indent_str;

size_t num_spaces = (loc.first_column - 1) - source_line.column_offset;
size_t num_spaces = 0;
if (loc.first_column > source_line.column_offset) {
num_spaces = (loc.first_column - 1) - source_line.column_offset;
}
size_t num_carets = loc.last_column - loc.first_column;
num_carets = std::min(num_carets, source_line.line.size() - num_spaces);
num_carets = std::max<size_t>(num_carets, 1);
Expand Down
8 changes: 8 additions & 0 deletions src/interp/interp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ Result Match(const Limits& expected,
}
}

if (expected.is_64 && !actual.is_64) {
*out_msg = StringPrintf("expected i64 memory, but i32 memory provided");
return Result::Error;
} else if (actual.is_64 && !expected.is_64) {
*out_msg = StringPrintf("expected i32 memory, but i64 memory provided");
return Result::Error;
}

return Result::Ok;
}

Expand Down
13 changes: 12 additions & 1 deletion src/shared-validator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,11 @@ Result SharedValidator::OnCallIndirect(const Location& loc,
TableType table_type;
result |= CheckFuncTypeIndex(sig_var, &func_type);
result |= CheckTableIndex(table_var, &table_type);
if (table_type.element != Type::FuncRef) {
result |= PrintError(
loc,
"type mismatch: call_indirect must reference table of funcref type");
}
result |= typechecker_.OnCallIndirect(func_type.params, func_type.results,
table_type.limits);
return result;
Expand Down Expand Up @@ -1028,9 +1033,15 @@ Result SharedValidator::OnReturnCallIndirect(const Location& loc,
Var sig_var,
Var table_var) {
Result result = CheckInstr(Opcode::CallIndirect, loc);
result |= CheckTableIndex(table_var);
FuncType func_type;
TableType table_type;
result |= CheckFuncTypeIndex(sig_var, &func_type);
result |= CheckTableIndex(table_var, &table_type);
if (table_type.element != Type::FuncRef) {
result |= PrintError(loc,
"type mismatch: return_call_indirect must reference "
"table of funcref type");
}
result |=
typechecker_.OnReturnCallIndirect(func_type.params, func_type.results);
return result;
Expand Down
14 changes: 0 additions & 14 deletions test/regress/data-count-without-data-section.txt

This file was deleted.

15 changes: 14 additions & 1 deletion test/spec/align.txt
Original file line number Diff line number Diff line change
Expand Up @@ -297,5 +297,18 @@ out/test/spec/align.wast:452: assert_invalid passed:
out/test/spec/align/align.105.wasm:000002a: error: alignment must not be larger than natural alignment (8)
000002a: error: OnStoreExpr callback failed
out/test/spec/align.wast:864: assert_trap passed: out of bounds memory access: access at 65532+8 >= max value 65536
156/156 tests passed.
out/test/spec/align.wast:873: assert_invalid passed:
out/test/spec/align/align.108.wasm:0000021: error: alignment must not be larger than natural alignment (4)
0000021: error: OnLoadExpr callback failed
out/test/spec/align.wast:892: assert_malformed passed:
0000020: error: invalid load alignment: 32
out/test/spec/align.wast:911: assert_malformed passed:
0000020: error: invalid load alignment: 33
out/test/spec/align.wast:930: assert_malformed passed:
0000020: error: invalid load alignment: 63
out/test/spec/align.wast:949: assert_malformed passed:
0000020: error: multi_memory not allowed
out/test/spec/align.wast:968: assert_malformed passed:
0000020: error: multi_memory not allowed
162/162 tests passed.
;;; STDOUT ;;)
122 changes: 84 additions & 38 deletions test/spec/binary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,79 +113,125 @@ out/test/spec/binary.wast:431: assert_malformed passed:
0000015: error: function signature count != function body count
out/test/spec/binary.wast:454: assert_malformed passed:
000000e: error: data segment count does not equal count in DataCount section
out/test/spec/binary.wast:464: assert_malformed passed:
out/test/spec/binary.wast:466: assert_malformed passed:
000000e: error: data segment count does not equal count in DataCount section
out/test/spec/binary.wast:474: assert_malformed passed:
out/test/spec/binary.wast:478: assert_malformed passed:
0000010: error: Data section missing but DataCount non-zero
out/test/spec/binary.wast:494: assert_malformed passed:
0000024: error: memory.init requires data count section
out/test/spec/binary.wast:496: assert_malformed passed:
out/test/spec/binary.wast:517: assert_malformed passed:
000001e: error: data.drop requires data count section
out/test/spec/binary.wast:515: assert_malformed passed:
out/test/spec/binary.wast:537: assert_malformed passed:
0000024: error: unexpected opcode: 0xf3
out/test/spec/binary.wast:541: assert_malformed passed:
out/test/spec/binary.wast:565: assert_malformed passed:
0000022: error: table elem type must be a reference type
out/test/spec/binary.wast:622: assert_malformed passed:
out/test/spec/binary.wast:650: assert_malformed passed:
000000a: error: invalid section size: extends past end
out/test/spec/binary.wast:633: assert_malformed passed:
out/test/spec/binary.wast:661: assert_malformed passed:
000000e: error: unfinished section (expected end: 0x11)
out/test/spec/binary.wast:652: assert_malformed passed:
out/test/spec/binary.wast:680: assert_malformed passed:
000000e: error: invalid import tag kind: exceptions not allowed
out/test/spec/binary.wast:662: assert_malformed passed:
out/test/spec/binary.wast:690: assert_malformed passed:
000000e: error: invalid import tag kind: exceptions not allowed
out/test/spec/binary.wast:673: assert_malformed passed:
out/test/spec/binary.wast:701: assert_malformed passed:
000000e: error: malformed import kind: 5
out/test/spec/binary.wast:683: assert_malformed passed:
out/test/spec/binary.wast:711: assert_malformed passed:
000000e: error: malformed import kind: 5
out/test/spec/binary.wast:694: assert_malformed passed:
out/test/spec/binary.wast:722: assert_malformed passed:
000000e: error: malformed import kind: 128
out/test/spec/binary.wast:704: assert_malformed passed:
out/test/spec/binary.wast:732: assert_malformed passed:
000000e: error: malformed import kind: 128
out/test/spec/binary.wast:717: assert_malformed passed:
out/test/spec/binary.wast:745: assert_malformed passed:
0000027: error: unable to read u32 leb128: string length
out/test/spec/binary.wast:736: assert_malformed passed:
out/test/spec/binary.wast:764: assert_malformed passed:
000002b: error: unfinished section (expected end: 0x40)
out/test/spec/binary.wast:767: assert_malformed passed:
out/test/spec/binary.wast:795: assert_malformed passed:
000000b: error: invalid table count 1, only 0 bytes left in section
out/test/spec/binary.wast:777: assert_malformed passed:
out/test/spec/binary.wast:805: assert_malformed passed:
000000d: error: tables may not be shared
out/test/spec/binary.wast:786: assert_malformed passed:
out/test/spec/binary.wast:814: assert_malformed passed:
000000d: error: tables may not be shared
out/test/spec/binary.wast:796: assert_malformed passed:
out/test/spec/binary.wast:824: assert_malformed passed:
000000d: error: malformed table limits flag: 129
out/test/spec/binary.wast:814: assert_malformed passed:
out/test/spec/binary.wast:842: assert_malformed passed:
000000b: error: invalid memory count 1, only 0 bytes left in section
out/test/spec/binary.wast:824: assert_malformed passed:
out/test/spec/binary.wast:852: assert_malformed passed:
000000c: error: memory may not be shared: threads not allowed
out/test/spec/binary.wast:832: assert_malformed passed:
out/test/spec/binary.wast:860: assert_malformed passed:
000000c: error: memory may not be shared: threads not allowed
out/test/spec/binary.wast:841: assert_malformed passed:
out/test/spec/binary.wast:869: assert_malformed passed:
000000c: error: malformed memory limits flag: 129
out/test/spec/binary.wast:850: assert_malformed passed:
out/test/spec/binary.wast:878: assert_malformed passed:
000000c: error: malformed memory limits flag: 129
out/test/spec/binary.wast:867: assert_malformed passed:
out/test/spec/binary.wast:895: assert_malformed passed:
0000010: error: unable to read i32 leb128: global type
out/test/spec/binary.wast:878: assert_malformed passed:
out/test/spec/binary.wast:906: assert_malformed passed:
0000010: error: unfinished section (expected end: 0x15)
out/test/spec/binary.wast:901: assert_malformed passed:
out/test/spec/binary.wast:929: assert_malformed passed:
000001b: error: unable to read u32 leb128: string length
out/test/spec/binary.wast:922: assert_malformed passed:
out/test/spec/binary.wast:950: assert_malformed passed:
000001b: error: unfinished section (expected end: 0x20)
out/test/spec/binary.wast:956: assert_malformed passed:
out/test/spec/binary.wast:984: assert_malformed passed:
0000021: error: unable to read u32 leb128: elem segment flags
out/test/spec/binary.wast:972: assert_malformed passed:
out/test/spec/binary.wast:1000: assert_malformed passed:
0000024: error: init expression must end with END opcode
out/test/spec/binary.wast:989: assert_malformed passed:
out/test/spec/binary.wast:1017: assert_malformed passed:
0000021: error: unfinished section (expected end: 0x27)
out/test/spec/binary.wast:1015: assert_malformed passed:
out/test/spec/binary.wast:1043: assert_malformed passed:
0000016: error: unable to read u32 leb128: data segment flags
out/test/spec/binary.wast:1028: assert_malformed passed:
out/test/spec/binary.wast:1056: assert_malformed passed:
0000016: error: unfinished section (expected end: 0x1c)
out/test/spec/binary.wast:1041: assert_malformed passed:
out/test/spec/binary.wast:1069: assert_malformed passed:
0000015: error: unable to read data: data segment data
out/test/spec/binary.wast:1055: assert_malformed passed:
out/test/spec/binary.wast:1083: assert_malformed passed:
000001a: error: unfinished section (expected end: 0x1b)
out/test/spec/binary.wast:1086: assert_malformed passed:
out/test/spec/binary.wast:1114: assert_malformed passed:
0000048: error: function body must end with END opcode
out/test/spec/binary.wast:1133: assert_malformed passed:
out/test/spec/binary.wast:1161: assert_malformed passed:
0000017: error: multiple Start sections
112/112 tests passed.
out/test/spec/binary.wast:1178: assert_malformed passed:
0000014: error: multiple Function sections
out/test/spec/binary.wast:1190: assert_malformed passed:
0000016: error: function signature count != function body count
out/test/spec/binary.wast:1202: assert_malformed passed:
000000d: error: multiple DataCount sections
out/test/spec/binary.wast:1212: assert_malformed passed:
000000d: error: multiple Data sections
out/test/spec/binary.wast:1222: assert_malformed passed:
000000d: error: multiple Global sections
out/test/spec/binary.wast:1232: assert_malformed passed:
000000d: error: multiple Export sections
out/test/spec/binary.wast:1242: assert_malformed passed:
000000d: error: multiple Table sections
out/test/spec/binary.wast:1252: assert_malformed passed:
000000d: error: multiple Elem sections
out/test/spec/binary.wast:1262: assert_malformed passed:
000000d: error: multiple Import sections
out/test/spec/binary.wast:1272: assert_malformed passed:
000000d: error: multiple Type sections
out/test/spec/binary.wast:1282: assert_malformed passed:
000000d: error: multiple Memory sections
out/test/spec/binary.wast:1292: assert_malformed passed:
000000d: error: section Type out of order
out/test/spec/binary.wast:1302: assert_malformed passed:
000000d: error: section Import out of order
out/test/spec/binary.wast:1312: assert_malformed passed:
000000d: error: section Function out of order
out/test/spec/binary.wast:1322: assert_malformed passed:
000000d: error: section Table out of order
out/test/spec/binary.wast:1332: assert_malformed passed:
000000d: error: section Memory out of order
out/test/spec/binary.wast:1342: assert_malformed passed:
000000d: error: section Global out of order
out/test/spec/binary.wast:1352: assert_malformed passed:
0000011: error: section Export out of order
out/test/spec/binary.wast:1363: assert_malformed passed:
0000011: error: section Start out of order
out/test/spec/binary.wast:1374: assert_malformed passed:
000000d: error: section Elem out of order
out/test/spec/binary.wast:1384: assert_malformed passed:
000000d: error: section DataCount out of order
out/test/spec/binary.wast:1394: assert_malformed passed:
000000d: error: section Code out of order
136/136 tests passed.
;;; STDOUT ;;)
21 changes: 14 additions & 7 deletions test/spec/call_indirect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ out/test/spec/call_indirect.wast:776: assert_malformed passed:
^^^^^^^^^^^^^
out/test/spec/call_indirect.wast:791: assert_invalid passed:
out/test/spec/call_indirect/call_indirect.13.wasm:000001c: error: table variable out of range: 0 (max 0)
out/test/spec/call_indirect/call_indirect.13.wasm:000001c: error: type mismatch: call_indirect must reference table of funcref type
000001c: error: OnCallIndirectExpr callback failed
out/test/spec/call_indirect.wast:799: assert_invalid passed:
out/test/spec/call_indirect/call_indirect.14.wasm:0000023: error: type mismatch in i32.eqz, expected [i32] but got []
Expand Down Expand Up @@ -141,14 +142,20 @@ out/test/spec/call_indirect.wast:961: assert_invalid passed:
out/test/spec/call_indirect.wast:977: assert_invalid passed:
out/test/spec/call_indirect/call_indirect.31.wasm:000003d: error: type mismatch in call_indirect, expected [i32, i32] but got [i32]
000003d: error: OnCallIndirectExpr callback failed
out/test/spec/call_indirect.wast:997: assert_invalid passed:
out/test/spec/call_indirect/call_indirect.32.wasm:0000022: error: function type variable out of range: 1 (max 1)
out/test/spec/call_indirect.wast:995: assert_invalid passed:
out/test/spec/call_indirect/call_indirect.32.wasm:0000022: error: type mismatch: call_indirect must reference table of funcref type
0000022: error: OnCallIndirectExpr callback failed
out/test/spec/call_indirect.wast:1004: assert_invalid passed:
out/test/spec/call_indirect/call_indirect.33.wasm:0000026: error: function type variable out of range: 1012321300 (max 1)
out/test/spec/call_indirect.wast:1006: assert_invalid passed:
out/test/spec/call_indirect/call_indirect.33.wasm:0000022: error: function type variable out of range: 1 (max 1)
0000022: error: OnCallIndirectExpr callback failed
out/test/spec/call_indirect.wast:1013: assert_invalid passed:
out/test/spec/call_indirect/call_indirect.34.wasm:0000026: error: function type variable out of range: 1012321300 (max 1)
0000026: error: OnCallIndirectExpr callback failed
out/test/spec/call_indirect.wast:1015: assert_invalid passed:
out/test/spec/call_indirect/call_indirect.34.wasm:0000018: error: function variable out of range: 0 (max 0)
out/test/spec/call_indirect.wast:1022: assert_invalid passed:
out/test/spec/call_indirect/call_indirect.35.wasm:000002e: error: function type variable out of range: 4294967295 (max 2)
000002e: error: OnCallIndirectExpr callback failed
out/test/spec/call_indirect.wast:1038: assert_invalid passed:
out/test/spec/call_indirect/call_indirect.36.wasm:0000018: error: function variable out of range: 0 (max 0)
0000018: error: OnRefFuncExpr callback failed
170/170 tests passed.
172/172 tests passed.
;;; STDOUT ;;)
Loading