Set a default value for slot in SharedMutex.h
authorMichael Lee <mzlee@fb.com>
Wed, 28 Sep 2016 00:31:22 +0000 (17:31 -0700)
committerFacebook Github Bot 2 <facebook-github-bot-2-bot@fb.com>
Wed, 28 Sep 2016 00:38:47 +0000 (17:38 -0700)
commitc532329ad0c24fa6ed9f119201ade738a5d623f4
tree1433a34424af25dd2f4334306ef9c8f5103e10d4
parent4b39d461103b3be68903e8e882d59e2f93c136ea
Set a default value for slot in SharedMutex.h

Summary:
`SharedMutexImpl::lockSharedImpl` has a potentially uninitialized access:

  Assume state = 0
  canAlreadyDefer = (state & kMayDefer) != 0 ==> false
  aboveDeferThreshold = (state & kHasS) >= (kNumSharedToStartDeferring - 1) * kIncrHasS ==> false

  if (canAlreadyDefer || (aboveDeferThreshold && !drainInProgress)) ==> false

  line:1452: gotSlot(slot)->compare_exchange_strong(...) uses slot uninitialized

Reviewed By: Orvid

Differential Revision: D3933638

fbshipit-source-id: 0fbce5c00b8b1f34e50c302cb88def97853c5afe
folly/SharedMutex.h