rocksdb/file
Mike Kolupaev 74b01ac2ea Fix use-after-free and double-deleting files in BackgroundCallPurge() (#6193)
Summary:
The bad code was:

```
mutex.Lock(); // `mutex` protects `container`
for (auto& x : container) {
  mutex.Unlock();
  // do stuff to x
  mutex.Lock();
}
```

It's incorrect because both `x` and the iterator may become invalid if another thread modifies the container while this thread is not holding the mutex.

Broken by https://github.com/facebook/rocksdb/pull/5796 - it replaced a `while (!container.empty())` loop with a `for (auto x : container)`.

(RocksDB code does a lot of such unlocking+re-locking of mutexes, and this type of bugs comes up a lot :/ )
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6193

Test Plan: Ran some logdevice integration tests that were crashing without this fix.

Differential Revision: D19116874

Pulled By: al13n321

fbshipit-source-id: 9672bc4227c1b68f46f7436db2b96811adb8c703
2020-01-02 12:21:53 -08:00
..
delete_scheduler_test.cc Apply formatter to recent 200+ commits. (#5830) 2019-09-20 12:04:26 -07:00
delete_scheduler.cc Fix use-after-free and double-deleting files in BackgroundCallPurge() (#6193) 2020-01-02 12:21:53 -08:00
delete_scheduler.h Move some file related files outside util/ (#5375) 2019-05-29 20:47:06 -07:00
file_prefetch_buffer.cc Divide file_reader_writer.h and .cc (#5803) 2019-09-16 10:33:51 -07:00
file_prefetch_buffer.h Divide file_reader_writer.h and .cc (#5803) 2019-09-16 10:33:51 -07:00
file_util.cc Divide file_reader_writer.h and .cc (#5803) 2019-09-16 10:33:51 -07:00
file_util.h Fix bugs in WAL trash file handling (#5520) 2019-07-06 21:07:32 -07:00
filename.cc Divide file_reader_writer.h and .cc (#5803) 2019-09-16 10:33:51 -07:00
filename.h Persistent globally unique DB ID in manifest (#5725) 2019-09-03 08:52:24 -07:00
random_access_file_reader.cc Divide file_reader_writer.h and .cc (#5803) 2019-09-16 10:33:51 -07:00
random_access_file_reader.h Divide file_reader_writer.h and .cc (#5803) 2019-09-16 10:33:51 -07:00
read_write_util.cc Dedup IsFileSectorAligned() to fix unity build. (#5812) 2019-09-16 20:42:07 -07:00
read_write_util.h Dedup IsFileSectorAligned() to fix unity build. (#5812) 2019-09-16 20:42:07 -07:00
readahead_raf.cc Dedup IsFileSectorAligned() to fix unity build. (#5812) 2019-09-16 20:42:07 -07:00
readahead_raf.h Divide file_reader_writer.h and .cc (#5803) 2019-09-16 10:33:51 -07:00
sequence_file_reader.cc Dedup IsFileSectorAligned() to fix unity build. (#5812) 2019-09-16 20:42:07 -07:00
sequence_file_reader.h Divide file_reader_writer.h and .cc (#5803) 2019-09-16 10:33:51 -07:00
sst_file_manager_impl.cc simplify include directive involving inttypes (#5402) 2019-06-06 13:56:07 -07:00
sst_file_manager_impl.h Organizing rocksdb/db directory 2019-05-31 11:57:01 -07:00
writable_file_writer.cc Divide file_reader_writer.h and .cc (#5803) 2019-09-16 10:33:51 -07:00
writable_file_writer.h Divide file_reader_writer.h and .cc (#5803) 2019-09-16 10:33:51 -07:00