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

SPARK-5984: Fix TimSort bug causes ArrayOutOfBoundsException #4804

Closed
wants to merge 6 commits into from

Conversation

hotou
Copy link
Contributor

@hotou hotou commented Feb 27, 2015

Fix TimSort bug which causes a ArrayOutOfBoundsException.

Using the proposed fix here
http://envisage-project.eu/proving-android-java-and-python-sorting-algorithm-is-broken-and-how-to-fix-it/

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@@ -65,6 +65,12 @@ class SorterSuite extends FunSuite {
}
}

test("bug of TimSort") {
Copy link
Contributor

Choose a reason for hiding this comment

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

would be good to provide a link to the original blog post

Copy link
Contributor

Choose a reason for hiding this comment

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

and would be better to include the JIRA ticket number, i.e.

test("SPARK-5984 TimSort bug") {
  ...
}

@rxin
Copy link
Contributor

rxin commented Feb 27, 2015

Thanks for submitting the patch. I left some minor comments.

* This codes generates a int array which fails the standard TimSort, Borrowed from
* the reporter of this bug.
*
* http://www.envisage-project.eu/timsort-specification-and-verification/
Copy link
Contributor

Choose a reason for hiding this comment

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

we should also link to the github repository with an explicit license https://github.com/abstools/java-timsort-bug

Copy link
Member

Choose a reason for hiding this comment

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

Yes that's good practice. For completeness, because this AL2 and because there is no additional NOTICE file, we don't need to do anything else to our LICENSE or NOTICE file.

@hotou
Copy link
Contributor Author

hotou commented Feb 28, 2015

@rxin @srowen Thanks for the review, I updated the comments and licensed info etc.

@rxin
Copy link
Contributor

rxin commented Feb 28, 2015

Jenkins, test this please.

@SparkQA
Copy link

SparkQA commented Feb 28, 2015

Test build #28105 has started for PR 4804 at commit 4d95f75.

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Feb 28, 2015

Test build #28105 has finished for PR 4804 at commit 4d95f75.

  • This patch fails RAT tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/28105/
Test FAILed.

@hotou
Copy link
Contributor Author

hotou commented Feb 28, 2015

Ah. I guess I have to have license file header in .java, not just linked to it


import java.util.*;

/*
Copy link
Contributor

Choose a reason for hiding this comment

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

you need to put this in the beginning of the file, i.e. before the package definition

@hotou
Copy link
Contributor Author

hotou commented Feb 28, 2015

ok

* https://github.com/abstools/java-timsort-bug
*
* Licensed under Apache License 2.0
* https://github.com/abstools/java-timsort-bug/blob/master/LICENSE
Copy link
Member

Choose a reason for hiding this comment

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

If this test code is your own work, then this statement is redundant with the license header, so would be removed.

But it's copied from the project above right? then you can't write a license header here that says it was licensed to the ASF. If anything we would reproduce the plain vanilla AL2 stanza from the plain AL2 license text up above in the file's license header.

That or not copy this test code. This Java code needs a bit more style work to match coding practices here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, it's not a exact copy, I made changes to the original codes.

Do you guys have a IntelliJ style that I can import ?

Copy link
Member

Choose a reason for hiding this comment

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

It looks like it's almost entirely the code from the third party site. The right-est thing to do is actually begin this file with the standard AL2 stanza:

Copyright 2015 [the author's name]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

... since that is substantially the license of the work in the file. I believe the build's check for this stuff will accept this, or should. It can be followed with a comment that the work has been modified from its original form.

I don't think it's crazy to omit this either, though always nice to have tests.

THere's no standard IJ config but I'll point out some things that could be touched up.

@hotou
Copy link
Contributor Author

hotou commented Feb 28, 2015

@srowen I did what you recommended here. This passed the rat test on my machine at least

@srowen
Copy link
Member

srowen commented Feb 28, 2015

OK, I apologize for belaboring this and hassle with the incorrect suggestion earlier. But I think we may have to do one more thing for the licensing to get it right, and we should. I believe we need an entry in our own LICENSE file after all, given the situation. You can see one for the copied TimSort. I'd just add it below that. Then it really does look good from a license perspective, AFAIK.

@hotou
Copy link
Contributor Author

hotou commented Feb 28, 2015

@srowen Sounds good, done.

@srowen
Copy link
Member

srowen commented Feb 28, 2015

Thanks @hotou this really looks buttoned up now. Go for it @rxin if it looks good to you or else I will merge tomorrow.

@rxin
Copy link
Contributor

rxin commented Feb 28, 2015

Let's give @aarondav a chance to look at this also since he's the guy that introduced the timsort.

@aarondav
Copy link
Contributor

LGTM as well.

@asfgit asfgit closed this in 643300a Mar 1, 2015
@rxin
Copy link
Contributor

rxin commented Mar 1, 2015

Thanks. I've merged this.

asfgit pushed a commit that referenced this pull request Mar 1, 2015
Fix TimSort bug which causes a ArrayOutOfBoundsException.

Using the proposed fix here
http://envisage-project.eu/proving-android-java-and-python-sorting-algorithm-is-broken-and-how-to-fix-it/

Author: Evan Yu <ehotou@gmail.com>

Closes #4804 from hotou/SPARK-5984 and squashes the following commits:

3421b6c [Evan Yu] SPARK-5984: Add info to LICENSE
e61c6b8 [Evan Yu] SPARK-5984: Fix license and document
6ccc280 [Evan Yu] SPARK-5984: Add License header to file
e06c0d2 [Evan Yu] SPARK-5984: Add License header to file
4d95f75 [Evan Yu] SPARK-5984: Fix TimSort bug causes ArrayOutOfBoundsException
479a106 [Evan Yu] SPARK-5984: Fix TimSort bug causes ArrayOutOfBoundsException

(cherry picked from commit 643300a)
Signed-off-by: Reynold Xin <rxin@databricks.com>
@hotou
Copy link
Contributor Author

hotou commented Mar 1, 2015

Thanks for the review guys

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.

6 participants