From 7441a0ecba355d1c7b8c21e5d37df4e0d0b212da Mon Sep 17 00:00:00 2001 From: Maysam Yabandeh Date: Wed, 3 Apr 2019 15:43:34 -0700 Subject: [PATCH] WriteUnPrepared: fix ubsan complaint (#5148) Summary: Ubsna complains that in initialization of WriteUnpreparedTxnReadCallback the method of the child class is used before the parent class is constructed. The patch fixes that by making the aforementioned method static. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5148 Differential Revision: D14760098 Pulled By: maysamyabandeh fbshipit-source-id: cf19b7c1fdb5de0a54e62c1deebe09a0fa048ded --- utilities/transactions/write_unprepared_txn.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/utilities/transactions/write_unprepared_txn.h b/utilities/transactions/write_unprepared_txn.h index 4a00406d7..68567eb6e 100644 --- a/utilities/transactions/write_unprepared_txn.h +++ b/utilities/transactions/write_unprepared_txn.h @@ -42,14 +42,15 @@ class WriteUnpreparedTxnReadCallback : public ReadCallback { // TODO(myabandeh): override Refresh when Iterator::Refresh is supported private: - SequenceNumber CalcMaxVisibleSeq(WriteUnpreparedTxn* txn, - SequenceNumber snapshot_seq) { + static SequenceNumber CalcMaxVisibleSeq(WriteUnpreparedTxn* txn, + SequenceNumber snapshot_seq) { SequenceNumber max_unprepared = CalcMaxUnpreparedSequenceNumber(txn); assert(snapshot_seq < max_unprepared || max_unprepared == 0 || snapshot_seq == kMaxSequenceNumber); return std::max(max_unprepared, snapshot_seq); } - SequenceNumber CalcMaxUnpreparedSequenceNumber(WriteUnpreparedTxn* txn); + static SequenceNumber CalcMaxUnpreparedSequenceNumber( + WriteUnpreparedTxn* txn); WritePreparedTxnDB* db_; WriteUnpreparedTxn* txn_; SequenceNumber wup_snapshot_;