rocksdb/file
Mike Kolupaev ce63eda6f0 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
2019-12-17 20:08:56 -08:00
..
delete_scheduler.cc Fix use-after-free and double-deleting files in BackgroundCallPurge() (#6193) 2019-12-17 20:08:56 -08:00
delete_scheduler.h Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
delete_scheduler_test.cc Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08: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 Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
file_util.h Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08: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 Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
random_access_file_reader.h Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
read_write_util.cc Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
read_write_util.h Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08: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 Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
sequence_file_reader.h Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
sst_file_manager_impl.cc Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
sst_file_manager_impl.h Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
writable_file_writer.cc Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00
writable_file_writer.h Introduce a new storage specific Env API (#5761) 2019-12-13 14:48:41 -08:00