[PATCH] D17639: [asan] Fix recvfrom.cc testcase failure in large parallel tests run.
Maxim Ostapenko via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 26 02:51:01 PST 2016
m.ostapenko created this revision.
m.ostapenko added reviewers: kcc, samsonov, eugenis, dvyukov.
m.ostapenko added subscribers: llvm-commits, ygribov.
m.ostapenko set the repository for this revision to rL LLVM.
This testcase currently fails on sanitizer-x86_64-linux buildbot with following error:
```
FAIL: AddressSanitizer-i386-linux :: TestCases/Linux/recvfrom.cc (524 of 1166)
******************** TEST 'AddressSanitizer-i386-linux :: TestCases/Linux/recvfrom.cc' FAILED ********************
Script:
--
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/clang_build/./bin/clang --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -m32 /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Linux/recvfrom.cc -o /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/clang_build/projects/compiler-rt/test/asan/I386LinuxConfig/TestCases/Linux/Output/recvfrom.cc.tmp && not /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/clang_build/projects/compiler-rt/test/asan/I386LinuxConfig/TestCases/Linux/Output/recvfrom.cc.tmp 2>&1 | FileCheck /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/test/asan/TestCases/Linux/recvfrom.cc
--
Exit Code: 2
Command Output (stderr):
--
FileCheck error: '-' is empty.
--
```
I haven't managed reproduce this on my local box, but here my thoughts about the issue:
I believe this failure happens because of race on port 1234 between AddressSanitizer-i386-linux and AddressSanitizer-x86_64-linux instances of recvfrom.cc testcase. This patch tries to resolve the issue by trying to use another port if 1234 has already acquired.
Repository:
rL LLVM
http://reviews.llvm.org/D17639
Files:
test/asan/TestCases/Linux/recvfrom.cc
Index: test/asan/TestCases/Linux/recvfrom.cc
===================================================================
--- test/asan/TestCases/Linux/recvfrom.cc
+++ test/asan/TestCases/Linux/recvfrom.cc
@@ -2,7 +2,6 @@
//
// RUN: %clangxx_asan %s -o %t && not %run %t 2>&1 | FileCheck %s
//
-// REQUIRES: broken
// UNSUPPORTED: android
#include <stdio.h>
@@ -14,8 +13,9 @@
#include <sys/socket.h>
#include <pthread.h>
-const int kPortNum = 1234;
+int kPortNum = 1234;
const int kBufSize = 10;
+pthread_mutex_t server_ready_mu = PTHREAD_MUTEX_INITIALIZER;
static void *server_thread_udp(void *data) {
char buf[kBufSize / 2];
@@ -29,9 +29,15 @@
serveraddr.sin_addr.s_addr = htonl(INADDR_ANY);
serveraddr.sin_port = htons(kPortNum);
- if (bind(sockfd, (struct sockaddr *) &serveraddr, sizeof(serveraddr)) < 0)
- fprintf(stderr, "ERROR on binding\n");
-
+ // In parallel test run we may already have acquired port 1234. Increase
+ // kPortNum until we found free port.
+ while (bind(sockfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr)) < 0) {
+ ++kPortNum;
+ serveraddr.sin_port = htons(kPortNum);
+ }
+ // Release the mutex since the server is ready now and kPortNum has proper
+ // value.
+ pthread_mutex_unlock(&server_ready_mu);
recvfrom(sockfd, buf, kBufSize, 0, NULL, NULL); // BOOM
// CHECK: {{WRITE of size 9 at 0x.* thread T1}}
// CHECK: {{ #1 0x.* in server_thread_udp.*recvfrom.cc:}}[[@LINE-2]]
@@ -66,6 +72,10 @@
serveraddr.sin_family = AF_INET;
memcpy((char *)&serveraddr.sin_addr.s_addr, (char *)server->h_addr,
server->h_length);
+
+ // Wait until the server found free port and initialized kPortNum with proper
+ // value.
+ pthread_mutex_lock(&server_ready_mu);
serveraddr.sin_port = htons(kPortNum);
sendto(sockfd, buf, strlen(buf), 0, (struct sockaddr *) &serveraddr,
sizeof(serveraddr));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17639.49163.patch
Type: text/x-patch
Size: 1896 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160226/3b330f3c/attachment-0001.bin>
More information about the llvm-commits
mailing list