Skip to content
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

fix: restrict actor exit codes to non-system codes #3653

Closed
wants to merge 1 commit into from

Conversation

alanshaw
Copy link
Member

@alanshaw alanshaw commented Sep 8, 2020

This PR restricts actor methods from exiting with a system exit code. If an actor aborts with a system exit code, it is caught and changed to an SysErrorIllegalActor.

This conveniently also guards against actors using negative exit codes.

In #3199 @anorth suggested changing Runtime.Abortf to do this check, but this function is used by the runtime itself to abort with system exit codes and would not guard against an actor calling panic(aerrors.New(exitcode.SysErrInsufficientFunds, "actor made a system error")) directly.

refs filecoin-project/test-vectors#15

@Kubuxu
Copy link
Contributor

Kubuxu commented Sep 8, 2020

These panics are also going through this recover.
In essence we need to split out the Abortf into actor runtime one and internal one, the internal one would have no such check.

@alanshaw
Copy link
Member Author

alanshaw commented Sep 8, 2020

Ah right, gotcha, because an actor can also call Send on the runtime for example and a legitimate system error there would then be SysErrorIllegalActor.

hmm, if we split Abortf we'd still need to somehow deal with guarding against an actor calling panic(aerrors.New(exitcode.SysErrInsufficientFunds, "actor made a system error")) directly.

@alanshaw alanshaw closed this Sep 8, 2020
@alanshaw alanshaw deleted the fix/restrict-actor-exit-codes branch September 8, 2020 10:00
@Kubuxu
Copy link
Contributor

Kubuxu commented Sep 8, 2020

Actors don't have access to aerrors package.
but we can add a sentinel function to aerrors.ActorError interface
In the form of:

type guard struct{}
type ActorError interface {
	error
	IsFatal() bool
	RetCode() exitcode.ExitCode
	guard() guard
}

Then nothing outside aerrors package can implement the ActorError interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants