rocksdb/env
Peter Dillinger 70bf5ef093 Avoid destroying default PosixEnv, safely (#11538)
Summary:
Use another static object to join threads instead.

This change is motivated by a case in which some code using NewLRUCache() -> ShardedCacheBase -> SemiStructuredUniqueIdGen -> GenerateRawUniqueId() -> Env::Default() was happening
during static destruction.

I didn't see anything else in PosixEnv or base classes that would cause a problem by not
destroying. (WinEnv is already not destroyed; see env_default.cc)

Pull Request resolved: https://github.com/facebook/rocksdb/pull/11538UndefinedBehaviorSanitizer: undefined-behavior env/env_test.cc:3561:23 in
$
```

Test Plan:
test added, which would previously fail with UBSAN:

```
$ ./env_test --gtest_filter=*Destruct*
Note: Google Test filter = *Destruct*
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from EnvTestMisc
[ RUN      ] EnvTestMisc.StaticDestruction
[       OK ] EnvTestMisc.StaticDestruction (0 ms)
[----------] 1 test from EnvTestMisc (0 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (0 ms total)
[  PASSED  ] 1 test.
env/env_test.cc:3561:23: runtime error: member call on address 0x7f7b96671ca8 which does not point to an object of type 'rocksdb::Env'
0x7f7b96671ca8: note: object is of type 'N7rocksdb12ConfigurableE'
 00 00 00 00  90 a7 f7 95 7b 7f 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'N7rocksdb12ConfigurableE'

Reviewed By: jowlyzhang

Differential Revision: D46737389

Pulled By: pdillinger

fbshipit-source-id: 0f80a443bf799ffc5641e898cf3a75f7d10a987b
2023-06-14 16:18:08 -07:00
..
composite_env.cc Remove RocksDB LITE (#11147) 2023-01-27 13:14:19 -08:00
composite_env_wrapper.h Remove RocksDB LITE (#11147) 2023-01-27 13:14:19 -08:00
emulated_clock.h Make SystemClock into a Customizable Class (#8636) 2021-09-21 09:23:48 -07:00
env.cc Remove FactoryFunc from LoadXXXObject (#11203) 2023-02-17 12:54:07 -08:00
env_basic_test.cc Remove RocksDB LITE (#11147) 2023-01-27 13:14:19 -08:00
env_chroot.cc Remove RocksDB LITE (#11147) 2023-01-27 13:14:19 -08:00
env_chroot.h Remove RocksDB LITE (#11147) 2023-01-27 13:14:19 -08:00
env_encryption.cc Remove FactoryFunc from LoadXXXObject (#11203) 2023-02-17 12:54:07 -08:00
env_encryption_ctr.h Remove RocksDB LITE (#11147) 2023-01-27 13:14:19 -08:00
env_posix.cc Avoid destroying default PosixEnv, safely (#11538) 2023-06-14 16:18:08 -07:00
env_test.cc Avoid destroying default PosixEnv, safely (#11538) 2023-06-14 16:18:08 -07:00
file_system.cc Remove FactoryFunc from LoadXXXObject (#11203) 2023-02-17 12:54:07 -08:00
file_system_tracer.cc Provide support for IOTracing for ReadAsync API (#9833) 2022-05-25 19:47:03 -07:00
file_system_tracer.h Provide support for IOTracing for ReadAsync API (#9833) 2022-05-25 19:47:03 -07:00
fs_posix.cc Ignore async_io ReadOption if FileSystem doesn't support it (#11296) 2023-03-17 14:57:09 -07:00
fs_readonly.h Remove RocksDB LITE (#11147) 2023-01-27 13:14:19 -08:00
fs_remap.cc Remove RocksDB LITE (#11147) 2023-01-27 13:14:19 -08:00
fs_remap.h Remove RocksDB LITE (#11147) 2023-01-27 13:14:19 -08:00
io_posix.cc Run clang-format on env/ folder (#10859) 2022-10-24 17:54:14 -07:00
io_posix.h Added placeholders for MADV defines (#10881) 2022-11-02 14:42:42 -07:00
io_posix_test.cc Print stack traces on frozen tests in CI (#10828) 2022-10-18 00:35:35 -07:00
mock_env.cc Change internal headers with duplicate names (#11408) 2023-05-17 11:27:09 -07:00
mock_env.h Run clang-format on env/ folder (#10859) 2022-10-24 17:54:14 -07:00
mock_env_test.cc Run clang-format on env/ folder (#10859) 2022-10-24 17:54:14 -07:00
unique_id_gen.cc New stable, fixed-length cache keys (#9126) 2021-12-16 17:15:13 -08:00
unique_id_gen.h Add hash_seed to Caches (#11391) 2023-05-09 22:24:26 -07:00