[SERVER-51485] dependency on absl internals in getCodePointLength Created: 11/Oct/20  Updated: 29/Oct/23  Resolved: 12/Oct/20

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 4.9.0

Type: Bug Priority: Major - P3
Reporter: Billy Donahue Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Problem/Incident
is caused by SERVER-50753 Support $indexOfBytes and $indexOfCP ... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Service arch 2020-10-19
Participants:
Linked BF Score: 0

 Description   

Reaching into the absl internals is dangerous.
It's unnecessary in this case, and should be avoided.

+ #include "mongo/platform/bits.h"
...
getCodePointLength
-    return absl::base_internal::CountLeadingZeros64(~(uint64_t(charByte) << (64 - 8)));
+    return countLeadingZeros64(~static_cast<unsigned char>(charByte)) - (64 - 8);
 }



 Comments   
Comment by Githook User [ 17/Oct/20 ]

Author:

{'name': 'Benety Goh', 'email': 'benety@mongodb.com', 'username': 'benety'}

Message: SERVER-51485 fix std::bitset out of bounds in test
Branch: master
https://github.com/mongodb/mongo/commit/5362f02f26313574e3aa8cadcc6fd66bc43f301b

Comment by Githook User [ 12/Oct/20 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-51485 getCodePointLength fix use of absl internals
Branch: master
https://github.com/mongodb/mongo/commit/8af06bb9c0cc00ff2bb62db6411a647a399dad2c

Comment by Billy Donahue [ 12/Oct/20 ]

I'm going to add a unit test for this function to str_test.cpp.
The function is currently untested!

Comment by Billy Donahue [ 11/Oct/20 ]

CR https://mongodbcr.appspot.com/696390001/

Comment by Billy Donahue [ 11/Oct/20 ]

trivial edit

Generated at Thu Feb 08 05:25:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.