Revision 36651d14eeefaa3b17740e70bceacb3e096fde1a authored by Maysam Yabandeh on 18 July 2017, 23:49:57 UTC, committed by Facebook Github Bot on 18 July 2017, 23:58:22 UTC
Summary:
Moving static AdaptationContext to outside function to bypass tsan's false report with static initializers.

It is because with optimization enabled std::atomic is simplified to as a simple read with no locks. The existing lock produced by static initializer is __cxa_guard_acquire which is apparently not understood by tsan as it is different from normal locks (__gthrw_pthread_mutex_lock).

This is a known problem with tsan:
https://stackoverflow.com/questions/27464190/gccs-tsan-reports-a-data-race-with-a-thread-safe-static-local
https://stackoverflow.com/questions/42062557/c-multithreading-is-initialization-of-a-local-static-lambda-thread-safe

A workaround that I tried was to move the static variable outside the function. It is not a good coding practice since it gives global visibility to variable but it is a hackish workaround until g++ tsan is improved.
Closes https://github.com/facebook/rocksdb/pull/2598

Differential Revision: D5445281

Pulled By: yiwu-arbug

fbshipit-source-id: 6142bd934eb5852d8fd7ce027af593ba697ed41d
1 parent 6e3ee01
History
File Mode Size
arcanist_util
buckifier
build_tools
cache
cmake
coverage
db
docs
env
examples
hdfs
include
java
memtable
monitoring
options
port
table
third-party
tools
util
utilities
.clang-format -rw-r--r-- 138 bytes
.deprecated_arcconfig -rw-r--r-- 566 bytes
.gitignore -rw-r--r-- 726 bytes
.travis.yml -rw-r--r-- 2.4 KB
AUTHORS -rw-r--r-- 247 bytes
CMakeLists.txt -rw-r--r-- 28.5 KB
CONTRIBUTING.md -rw-r--r-- 607 bytes
COPYING -rw-r--r-- 17.7 KB
DEFAULT_OPTIONS_HISTORY.md -rw-r--r-- 1.5 KB
DUMP_FORMAT.md -rw-r--r-- 763 bytes
HISTORY.md -rw-r--r-- 45.8 KB
INSTALL.md -rw-r--r-- 5.7 KB
LANGUAGE-BINDINGS.md -rw-r--r-- 712 bytes
LICENSE.Apache -rw-r--r-- 11.1 KB
LICENSE.leveldb -rw-r--r-- 1.5 KB
Makefile -rw-r--r-- 58.0 KB
README.md -rw-r--r-- 1.4 KB
ROCKSDB_LITE.md -rw-r--r-- 1.0 KB
TARGETS -rw-r--r-- 20.0 KB
USERS.md -rw-r--r-- 4.9 KB
Vagrantfile -rw-r--r-- 877 bytes
WINDOWS_PORT.md -rw-r--r-- 12.5 KB
appveyor.yml -rw-r--r-- 416 bytes
src.mk -rw-r--r-- 25.7 KB
thirdparty.inc -rw-r--r-- 7.8 KB

README.md

back to top