qqiangwu / cppsafe

Cpp lifetime safety profile static analyzer
MIT License
39 stars 1 forks source link

rocksdb: point to local and reset at exit #78

Open qqiangwu opened 3 months ago

qqiangwu commented 3 months ago
TEST_P(ColumnFamilyTest, FlushCloseWALFiles) {
  SpecialEnv env(Env::Default());
  db_options_.env = &env;
  db_options_.max_background_flushes = 1;

  column_family_options_.memtable_factory.reset(test::NewSpecialSkipListFactory(2));
  Open();
  CreateColumnFamilies({"one"});
  ASSERT_OK(Put(1, "fodor", "mirko"));
  ASSERT_OK(Put(0, "fodor", "mirko"));
  ASSERT_OK(Put(1, "fodor", "mirko"));
}

at exit, db_options_.env refers to an expired object. using scoped_guard cannot solve the problem.