folly: futexWaitUntilImpl: avoid abort triggered via tao/queues tests
authorJim Meyering <meyering@fb.com>
Wed, 25 Jun 2014 23:47:55 +0000 (16:47 -0700)
committerNicholas Ormrod <njormrod@fb.com>
Fri, 27 Jun 2014 22:07:42 +0000 (15:07 -0700)
Summary:
* folly/test/DeterministicSchedule.cpp (folly): Tao/queues tests exposed
an unhandled case in this code: when (futex->data == expected) happens,
we would call futexErrnoToFutexResult with a futexErrno value of 0,
which would cause an abort (unhandled valued in switch).
Here's a stack trace from the abort: https://phabricator.fb.com/P12558008
showing the invalid futexErrno value in frame #4.

Test Plan:
fbconfig -r --platform-all=gcc-4.8.1-glibc-2.17 --sanitize=address tao/queues:TimeoutWorkQueueTests
_bin/tao/queues/WorkQueueTests -fbunit_test_regexp '^mt\_stress\_deterministic$'

Reviewed By: mssarang@fb.com

FB internal diff: D1404572

Tasks: 4494871

folly/test/DeterministicSchedule.cpp

index 4da4844321a207a5ece52806d05964a55562f5fb..f4c355e065d0101c91ada7b2e7e0a8d96195c7ba 100644 (file)
@@ -294,6 +294,8 @@ FutexResult futexWaitUntilImpl(Futex<DeterministicAtomic>* futex,
         break;
       }
     }
+  } else {
+    futexErrno = EWOULDBLOCK;
   }
   futexLock.unlock();
   DeterministicSchedule::afterSharedAccess();