Skip to content

Conversation

@obastemur
Copy link
Collaborator

OS14289876 credit goes to @jianchun

@obastemur obastemur requested a review from jianchun October 20, 2017 09:40
@jianchun
Copy link

            bucketCount = 0;

If other.Count() == 0 (because count == freeCount but bucketCount != 0), this could result in bad modFunctionIndex.


Refers to: lib/Common/DataStructures/BaseDictionary.h:153 in 1339070. [](commit_id = 1339070, deletion_comment = False)

@jianchun
Copy link

        this->freeCount = 0;

Here modFunctionIndex missing update.


Refers to: lib/Common/DataStructures/BaseDictionary.h:302 in 1339070. [](commit_id = 1339070, deletion_comment = False)

@jianchun
Copy link

            bucketCount = 0;

Missing modFunctionIndex update.


Refers to: lib/Common/DataStructures/BaseDictionary.h:311 in 1339070. [](commit_id = 1339070, deletion_comment = False)

@jianchun
Copy link

        uint newBucketCount = SizePolicy::GetBucketSize(newSize, &modFunctionIndex);

In theory this is not safe. this->modFunctionIndex is changed while other variables are not (newSize, newBucketCount are using temporaries). If anything below failed in the middle we'd end up with bad modFunctionIndex. To be consistent and safer, consider also use a temporary "newModFunctionIndex" and be sure use it during rehash.


Refers to: lib/Common/DataStructures/BaseDictionary.h:1021 in 1339070. [](commit_id = 1339070, deletion_comment = False)

@jianchun
Copy link

jianchun commented Oct 20, 2017

Please also fix WeaklyReferencedKeyDictionary::Resize() and Initialize(), both have the same unsafe pattern of changing modFunctionIndex before everything succeeds.

Any other dictionaries using modFunctionIndex having the same problem?

@obastemur
Copy link
Collaborator Author

@jianchun please consider that the mod index set by previous dictionary was working for that dictionary.

@jianchun
Copy link

@jianchun please consider that the mod index set by previous dictionary was working for that dictionary.

Yes it is a bug. But that's not the only problem. Several from my comments are apparent bugs too. The observation is that we have similar amount of failures in WeaklyReferencedKeyDictionary, which was not covered by current change. Why not do a thorough review and fix?

@obastemur
Copy link
Collaborator Author

@jianchun Thank you for the review and pointers. Is it good to go?

@obastemur obastemur force-pushed the modf_copy branch 3 times, most recently from 3080416 to c9330b1 Compare November 3, 2017 19:18
@chakrabot chakrabot merged commit eb29330 into chakra-core:release/1.7 Nov 3, 2017
chakrabot pushed a commit that referenced this pull request Nov 3, 2017
Merge pull request #4018 from obastemur:modf_copy

OS14289876 credit goes to @jianchun
chakrabot pushed a commit that referenced this pull request Nov 3, 2017
… on copy

Merge pull request #4018 from obastemur:modf_copy

OS14289876 credit goes to @jianchun
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.

3 participants