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 assertion failure in JavascriptArray.cpp #6846

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ShortDevelopment
Copy link
Contributor

Fix #6770

@rhuanjl (Could you please tag this PR with hacktoberfest-accepted?)

@rhuanjl
Copy link
Collaborator

rhuanjl commented Oct 3, 2022

Please can you add a test case for this?

@ShortDevelopment
Copy link
Contributor Author

Sure, but it seems like I’ve created a new assertion failure; I’ll have another look at this…

@ShortDevelopment
Copy link
Contributor Author

Problem is, that the assertion error only occurred with extremely large arrays.
Using the poc of the mentioned issue causes the test to timeout.

@rhuanjl
Copy link
Collaborator

rhuanjl commented Oct 3, 2022

The timeouts are on a per JS file basis - does it still timeout if this test is done in a separate file with nothing else?

Comment on lines -9487 to +9488
Assert(fromVal < MaxArrayLength);
Assert(toVal < MaxArrayLength);
Assert(direction == -1 || (fromVal + count < MaxArrayLength && toVal + count < MaxArrayLength));
Assert(direction != -1 || (fromVal < MaxArrayLength && toVal < MaxArrayLength));
Assert(fromVal + count <= MaxArrayLength && toVal + count <= MaxArrayLength);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be obvious, but what is going on in these asserts should be to opposite of the condition for "slower path" above (currently line 9460) which reads like "backwards and from/to large OR from+count/to+count large'. I suspect the assert that is tripping is off by one element, or maybe overflowing, not sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, it was not the logical opposite of the condition; now it should.

off by one

It used to say < instead of <=...

I'm in general not sure, why asserts are used in such places at all; Why checking a condition, that is just checked above (if)??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or do you mean, that we may need to change the if condition itself?!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not, just curious why this way works. I thought the conditions in asserts are the way they because "faster path" can only handle indices within certain range.

Copy link
Member

@ppenzin ppenzin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the timeout, is there a better way to go about the test? The array copy of such size if going to be slow.

Comment on lines -9487 to +9488
Assert(fromVal < MaxArrayLength);
Assert(toVal < MaxArrayLength);
Assert(direction == -1 || (fromVal + count < MaxArrayLength && toVal + count < MaxArrayLength));
Assert(direction != -1 || (fromVal < MaxArrayLength && toVal < MaxArrayLength));
Assert(fromVal + count <= MaxArrayLength && toVal + count <= MaxArrayLength);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not, just curious why this way works. I thought the conditions in asserts are the way they because "faster path" can only handle indices within certain range.

@rhuanjl
Copy link
Collaborator

rhuanjl commented Oct 5, 2022

Could the test complete in 3 minutes? Normally each test file gets a 1 min timeout but tests run with the Slow tag get 3 minutes instead (and are limited to only a couple of the test builds though that's not the point here).

If even 3 minutes is too short I don't know what to do - an Assert we can't test seems pointless. @ppenzin thoughts?

@ppenzin
Copy link
Member

ppenzin commented Oct 6, 2022

I agree, we should try to run it as a separate test and mark as slow (given it does finish in 3 minutes).

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.

Assertion failure in JavascriptArray.cpp
3 participants