History

Change assert to exception if a dis module contains an invalid magic number. Broken threads now terminate the VM using the default scheduler. Tools can not get a callback for broken threads.

arr committed 10 years ago

Commit 096b0c71 parent 9c1abd69 files · +74 −28Browse files

Showing the changes to src/vm/module_reader.cpp (1 of 9 files). Show all

Unified · Split

src/vm/module_reader.cpp+5−3
@@ -216,8 +216,6 @@ namespace · 215 unmodified lines
216216 if (!success)
217217 throw module_reader_exception{ "Failed to read magic number" };
218218
219− assert(header.magic_number == magic_number_constants::xmagic || header.magic_number == magic_number_constants::smagic);
220−
221219 // If the object file is signed, read in the signature.
222220 if (header.magic_number == magic_number_constants::smagic)
223221 {
@@ -228,10 +226,14 @@ namespace · 4 unmodified lines
228226 const auto bytesRead = reader.get_next_bytes(header.Signature.length, header.Signature.signature.get());
229227 if (bytesRead != header.Signature.length) throw module_reader_exception{ "Failed to read full signature" };
230228 }
231− else
229+ else if (header.magic_number == magic_number_constants::xmagic)
232230 {
233231 header.Signature.length = word_t{ 0 };
234232 }
233+ else
234+ {
235+ throw module_reader_exception{ "Invalid magic number in module" };
236+ }
235237
236238 auto runtime_flags = operand_t{};
237239 std::tie(success, runtime_flags) = read_next_operand(reader);