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

fix gcc warning about dangling-reference in backup_engine_test #12637

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 12 additions & 12 deletions utilities/backup/backup_engine_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4406,9 +4406,9 @@ TEST_F(BackupEngineTest, ExcludeFiles) {
delete db;
db = nullptr;

for (auto be_pair :
{std::make_pair(backup_engine_.get(), alt_backup_engine),
std::make_pair(alt_backup_engine, backup_engine_.get())}) {
auto backup_engine = backup_engine_.get();
for (auto be_pair : {std::make_pair(backup_engine, alt_backup_engine),
std::make_pair(alt_backup_engine, backup_engine)}) {
ASSERT_OK(DestroyDB(dbname_, options_));
RestoreOptions ro;
// Fails without alternate dir
Expand All @@ -4430,9 +4430,9 @@ TEST_F(BackupEngineTest, ExcludeFiles) {
CloseBackupEngine();
OpenBackupEngine();
Comment on lines 4430 to 4431
Copy link
Contributor

Choose a reason for hiding this comment

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

Can backup_engine become a dangling pointer here? I am wondering if this caused a subsequent use of backup_engine to segfault in https://github.com/facebook/rocksdb/actions/runs/9033386298/job/24823630007?pr=12637

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. I ignored the change of backup_engine_ before. I've modified code to assign backup_engine_.get() to backup_engine when backup_engine_ changed.


for (auto be_pair :
{std::make_pair(backup_engine_.get(), alt_backup_engine),
std::make_pair(alt_backup_engine, backup_engine_.get())}) {
backup_engine = backup_engine_.get();
for (auto be_pair : {std::make_pair(backup_engine, alt_backup_engine),
std::make_pair(alt_backup_engine, backup_engine)}) {
ASSERT_OK(DestroyDB(dbname_, options_));
RestoreOptions ro;
ro.alternate_dirs.push_front(be_pair.second);
Expand All @@ -4459,9 +4459,9 @@ TEST_F(BackupEngineTest, ExcludeFiles) {
AssertBackupInfoConsistency(/*allow excluded*/ true);

// Excluded file(s) deleted, unable to restore
for (auto be_pair :
{std::make_pair(backup_engine_.get(), alt_backup_engine),
std::make_pair(alt_backup_engine, backup_engine_.get())}) {
backup_engine = backup_engine_.get();
for (auto be_pair : {std::make_pair(backup_engine, alt_backup_engine),
std::make_pair(alt_backup_engine, backup_engine)}) {
RestoreOptions ro;
ro.alternate_dirs.push_front(be_pair.second);
ASSERT_TRUE(be_pair.first->RestoreDBFromLatestBackup(dbname_, dbname_, ro)
Expand All @@ -4475,9 +4475,9 @@ TEST_F(BackupEngineTest, ExcludeFiles) {
AssertBackupInfoConsistency(/*allow excluded*/ true);

// Excluded file(s) deleted, unable to restore
for (auto be_pair :
{std::make_pair(backup_engine_.get(), alt_backup_engine),
std::make_pair(alt_backup_engine, backup_engine_.get())}) {
backup_engine = backup_engine_.get();
for (auto be_pair : {std::make_pair(backup_engine, alt_backup_engine),
std::make_pair(alt_backup_engine, backup_engine)}) {
RestoreOptions ro;
ro.alternate_dirs.push_front(be_pair.second);
ASSERT_TRUE(be_pair.first->RestoreDBFromLatestBackup(dbname_, dbname_, ro)
Expand Down