-
Notifications
You must be signed in to change notification settings - Fork 212
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
test(xsnap): size limits #2681
test(xsnap): size limits #2681
Conversation
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 I read this right, we're checking that:
- medium numbers of property names work, large numbers fail with a
not enough keys
error - using
eval
to parse large1+1,1+1,...
strings works until about 1MiB, then fails (with an indeterminate error) - building large TypedArrays fails with an indeterminate error that cannot be caught
That sounds pretty good. I'd like to be confident that the engine is catching these problems and exiting with a panic (SIGABRT or SIGKILL), rather than segfaulting (SIGSEGV). Is there any way we can check that? Maybe look for a particular message text?
If we're demonstrating the uncatchability of OOM in the last test, should we also do a catch
for the first two?
Is a 1MiB limit for eval
large enough to load our contract bundles? That seems kind of small compared to the bundle sizes I've seen. If that's the sort of thing we add control over (maybe in an option to xsnap()
), we might want to have a test that shows a string of size N fails to eval
when the option is set below N, but succeeds when the option is increased.
yes.
the intent was at least 1MiB. I think on my machine it gets 3 or 4 iterations past that.
yes.
I believe the xsnap API returns the actual signal. I know it at least knows the signal internally, so I can surface it for this purpose.
I suppose so.
No ideer. I picked it arbitrarily.
I asked about an xsnap option in #2652 (comment) but feedback from @kriskowal suggested it's not time yet. @kriskowal is it time now? |
e81292a
to
165ac31
Compare
fixed in 165ac31 . turns out XS is pretty well-behaved when parsing long strings (it was exiting with "too much computation" in previous tests). What it doesn't like is long string literals. But even then
turns out xsnap was catching these errors but exiting with a 0 status code. In 3f5b9f0 we expose the exit code (and test for it).
done in 445d327 |
1993, /* parserTableModulo */ | ||
}; | ||
xsCreation* creation = &_creation; | ||
int parserBufferSize = 8192 * 1024; |
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.
Maybe let's make that an unsigned int
? Since atoi
accepts -1234
, it might be an extra safety belt.
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.
you want it to underflow and wrap around? I don't understand why.
} | ||
} | ||
} catch (err) { | ||
// name space exhaustion should not be catchable! |
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.
Good, but if this managed to catch the first few times, and then stopped catching it, we'd not be able to distinguish that failure mode from the intended one. Would it be possible to have the catch
clause raise an exception that would cause the worker to exit with something measurably different (something other than exited with code 6
) ?
If that's too much hassle, just having it print a "wait a minute I shouldn't be printed" and manually eyeball it once should be sufficient.
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.
I don't understand your point. The try ... catch
is outside the for
loop, so it catches either 0 or 1 times. If it catches, the vat.evaluate
won't reject, so it'll fail t.throwsAsync
.
In any case, I put a for-ever loop in the catch block to exit with "too much computation" in 0b4501f .
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.
Minor changes suggested, but if they're too intrusive then feel free land without them.
packages/xsnap/test/test-xsnap.js
Outdated
await t.throwsAsync(vat.evaluate(`for (;;) {}`), { | ||
message: 'xsnap test worker exited', | ||
message: /exited with code 7/, |
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.
This no longer validates the xsnap
name
option.
Might it make sense for the xsnap
utility to convert machine error codes into humane error messages? There’s Node.js precedent for having an error.code
property for automated recovery logic.
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.
This no longer validates the
xsnap
name
option.
The test label said it was about infinite loops, not the name option. But OK, this is a regression, so I un-did it in b349045 .
Might it make sense for the
xsnap
utility to convert machine error codes into humane error messages? There’s Node.js precedent for having anerror.code
property for automated recovery logic.
Perhaps... but I prefer to postpone it indefinitely as a separate issue: #2749 .
- lint: globals, ava devDependencies
- enable promise loop test - check exit codes in tests
just getting started on limits
the goal is:
fixes #2652