-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes a panic in the wasm executor when entrypoint is not known #3779
Conversation
Important Auto Review SkippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the To trigger a single review, invoke the TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
pkg/executor/wasm/handler.go
Outdated
if r := recover(); r != nil { | ||
h.logger.Error(). | ||
Str("recover", fmt.Sprintf("%v", r)). | ||
Msg("execution recovered from panic") | ||
// TODO don't do this. | ||
h.result = &models.RunCommandResult{} | ||
} |
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.
If we are 100% sure the code called below here won't panic then I am for removing this defer statement, otherwise I'd find it safer to leave it here.
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.
If we leave it, then I'd suggest we change it to returning an error instead as at the moment it makes it look like the execution succeeded.
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.
That sounds good to me. Basically do what was done here:
h.result = executor.NewFailedResult(
fmt.Sprintf("unable to find the entrypoint '%s' in the WASM module", h.arguments.EntryPoint),
)
return
but change the error message to state a panic occurred?
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.
Done in 94b9c8e
Currently we try to reference the `ExportedFunction` which is documented as returning nil when the name is not found. Instead it returns a non-nil object with an inner nil field which will cause a panic when `Call`-ed. This commit instead looks up the function before referencing it to ensure it exists, returning an error early if not. This allows us to remove the call to recover which was handling the panic() for us.
3fc381a
to
3c8736e
Compare
Currently we try to reference the `ExportedFunction` which is documented as returning nil when the name is not found. Instead it returns a non-nil object with an inner nil field which will cause a panic when `Call`-ed. This commit instead looks up the function before referencing it to ensure it exists, returning an error early if not. This allows us to remove the call to recover which was handling the panic() for us. Fixes #3753
Currently we try to reference the
ExportedFunction
which is documented as returning nil when the name is not found. Instead it returns a non-nil object with an inner nil field which will cause a panic whenCall
-ed.This commit instead looks up the function before referencing it to ensure it exists, returning an error early if not. This allows us to remove the call to recover which was handling the panic() for us.
Fixes #3753