From 5bda4d46d168a764ef5ea69e7527fec65a7e473f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 17 Mar 2016 17:27:11 -0700 Subject: [PATCH 1/3] Disable PIE --- Makefile | 8 ++++---- build.yaml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 6b93dee7e60..6b9e50736e5 100644 --- a/Makefile +++ b/Makefile @@ -188,8 +188,8 @@ CC_tsan = clang CXX_tsan = clang++ LD_tsan = clang LDXX_tsan = clang++ -CPPFLAGS_tsan = -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS -LDFLAGS_tsan = -fsanitize=thread -fPIE -pie +CPPFLAGS_tsan = -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS +LDFLAGS_tsan = -fsanitize=thread DEFINES_tsan += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=5 VALID_CONFIG_stapprof = 1 @@ -225,8 +225,8 @@ CC_etsan = clang CXX_etsan = clang++ LD_etsan = clang LDXX_etsan = clang++ -CPPFLAGS_etsan = -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS -LDFLAGS_etsan = -fsanitize=thread -fPIE -pie +CPPFLAGS_etsan = -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS +LDFLAGS_etsan = -fsanitize=thread DEFINES_etsan = _DEBUG DEBUG GRPC_EXECUTION_CONTEXT_SANITIZER DEFINES_etsan += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=5 diff --git a/build.yaml b/build.yaml index 73f5ac4e4ad..02a83441e51 100644 --- a/build.yaml +++ b/build.yaml @@ -2765,11 +2765,11 @@ configs: etsan: CC: clang CPPFLAGS: -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument - -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS + -DGPR_NO_DIRECT_SYSCALLS CXX: clang++ DEFINES: _DEBUG DEBUG GRPC_EXECUTION_CONTEXT_SANITIZER LD: clang - LDFLAGS: -fsanitize=thread -fPIE -pie + LDFLAGS: -fsanitize=thread LDXX: clang++ compile_the_world: true test_environ: @@ -2821,10 +2821,10 @@ configs: tsan: CC: clang CPPFLAGS: -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument - -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS + -DGPR_NO_DIRECT_SYSCALLS CXX: clang++ LD: clang - LDFLAGS: -fsanitize=thread -fPIE -pie + LDFLAGS: -fsanitize=thread LDXX: clang++ compile_the_world: true test_environ: From 4ce09cf760db8771f9c9b222d6f06df61c058ff7 Mon Sep 17 00:00:00 2001 From: vjpai Date: Fri, 18 Mar 2016 23:09:15 -0700 Subject: [PATCH 2/3] Reorder a release store after the operations it protects. --- src/core/iomgr/fd_posix.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c index 4ba7c5df943..3edafa0b070 100644 --- a/src/core/iomgr/fd_posix.c +++ b/src/core/iomgr/fd_posix.c @@ -72,6 +72,9 @@ static grpc_fd *fd_freelist = NULL; static gpr_mu fd_freelist_mu; static void freelist_fd(grpc_fd *fd) { + // Note that this function must be called after a release store (or + // full-barrier operation) on refst so that prior actions on the fd are + // ordered before the fd becomes visible to the freelist gpr_mu_lock(&fd_freelist_mu); fd->freelist_next = fd_freelist; fd_freelist = fd; @@ -92,7 +95,6 @@ static grpc_fd *alloc_fd(int fd) { gpr_mu_init(&r->mu); } - gpr_atm_rel_store(&r->refst, 1); r->shutdown = 0; r->read_closure = CLOSURE_NOT_READY; r->write_closure = CLOSURE_NOT_READY; @@ -104,6 +106,11 @@ static grpc_fd *alloc_fd(int fd) { r->on_done_closure = NULL; r->closed = 0; r->released = 0; + // The last operation on r before returning it should be a release-store + // so that all the above fields are globally visible before the value of + // r could escape to another thread. Our refcount itself needs a release-store + // so use this + gpr_atm_rel_store(&r->refst, 1); return r; } From c0e3952d274a1e262dcf2ad313271775cd360c1c Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Sat, 19 Mar 2016 05:53:21 -0700 Subject: [PATCH 3/3] Re-enable tsan for qps tests --- build.yaml | 4 ---- tools/run_tests/tests.json | 8 ++------ 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/build.yaml b/build.yaml index fc13d04264a..5f61e18c0aa 100644 --- a/build.yaml +++ b/build.yaml @@ -2452,8 +2452,6 @@ targets: - gpr_test_util - gpr - grpc++_test_config - exclude_configs: - - tsan platforms: - mac - linux @@ -2473,8 +2471,6 @@ targets: - gpr_test_util - gpr - grpc++_test_config - exclude_configs: - - tsan platforms: - mac - linux diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json index 099a516709c..2be7d8a48a8 100644 --- a/tools/run_tests/tests.json +++ b/tools/run_tests/tests.json @@ -2296,9 +2296,7 @@ "posix" ], "cpu_cost": 10, - "exclude_configs": [ - "tsan" - ], + "exclude_configs": [], "flaky": false, "gtest": false, "language": "c++", @@ -2317,9 +2315,7 @@ "posix" ], "cpu_cost": 10, - "exclude_configs": [ - "tsan" - ], + "exclude_configs": [], "flaky": false, "gtest": false, "language": "c++",