Skip to content

Commit 9526da8

Browse files
committed
Fix the logic of setting read_amp_bytes_per_bit from OPTIONS file (facebook#7680)
Summary: Instead of using `EncodeFixed32` which always serialize a integer to little endian, we should use the local machine's endianness when populating a native data structure during options parsing. Without this fix, `read_amp_bytes_per_bit` may be populated incorrectly on big-endian machines. Pull Request resolved: facebook#7680 Test Plan: make check Reviewed By: pdillinger Differential Revision: D24999166 Pulled By: riversand963 fbshipit-source-id: dc603cff6e17f8fa32479ce6df93b93082e6b0c4
1 parent 35d8e36 commit 9526da8

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
## 6.14.5 (11/15/2020)
33
### Bug Fixes
44
* Fix a bug of encoding and parsing BlockBasedTableOptions::read_amp_bytes_per_bit as a 64-bit integer.
5+
* Fixed the logic of populating native data structure for `read_amp_bytes_per_bit` during OPTIONS file parsing on big-endian architecture. Without this fix, original code introduced in PR7659, when running on big-endian machine, can mistakenly store read_amp_bytes_per_bit (an uint32) in little endian format. Future access to `read_amp_bytes_per_bit` will give wrong values. Little endian architecture is not affected.
56

67
## 6.14.4 (11/05/2020)
78
### Bug Fixes

table/block_based/block_based_table_factory.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ static std::unordered_map<std::string, OptionTypeInfo>
347347
// generated by affected releases before the fix, we need to
348348
// manually parse read_amp_bytes_per_bit with this special hack.
349349
uint64_t read_amp_bytes_per_bit = ParseUint64(value);
350-
EncodeFixed32(addr, static_cast<uint32_t>(read_amp_bytes_per_bit));
350+
*(reinterpret_cast<uint32_t*>(addr)) =
351+
static_cast<uint32_t>(read_amp_bytes_per_bit);
351352
return Status::OK();
352353
}}},
353354
{"enable_index_compression",

0 commit comments

Comments
 (0)