This repository has been archived by the owner on May 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 147
Warn when modules are missing before attempting disassembly #90
Open
gballet
wants to merge
3
commits into
go-interpreter:master
Choose a base branch
from
gballet:warn-missing-modules
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It won't work otherwise, and the error will be very confusing.
thanks, but it seems this breaks a bunch of tests. |
It seems to trigger a lot of issues that I missed out, indeed. I'm going to fix those in several commits over the next few days. |
sbinet
reviewed
Oct 30, 2018
|
||
// We already read the file without trying to resolve imports, | ||
// start over in order to do that work now. | ||
f.Seek(0, os.SEEK_SET) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/os.SEEK_SET/io.SeekStart/
// Decode the module in order to fake its imports as exports | ||
mod, err := wasm.DecodeModule(f) | ||
if err != nil { | ||
log.Fatalf("Could not read module: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Could/could/
ninternal, _ := leb128.ReadVarint32(bytes.NewReader(module.Code.Bytes)) | ||
nexternal := len(module.FunctionIndexSpace) - int(ninternal) | ||
if nexternal != len(module.Import.Entries) { | ||
panic(fmt.Sprintf("Attempting to disassemble a module that is missing imports %d != %d", nexternal, len(module.Import.Entries))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/fmt.Sprintf/fmt.Errorf/
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The goal is to catch the error early, otherwise it will cause a very confusing
disasm: stack underflow
which makes debugging very difficult.