1. 03 Nov, 2018 1 commit
    • Nathan Bronson's avatar
      test auto-heterogeneity for fbstring · 9f56897b
      Nathan Bronson authored
      Summary:
      This extends the unit tests for auto-transparent hash and
      equality to verify that they apply to fbstring.
      
      Reviewed By: froody
      
      Differential Revision: D12908619
      
      fbshipit-source-id: cdff815be6cb8fda6695cf745b20181f81ee0dd9
      9f56897b
  2. 02 Nov, 2018 20 commits
    • Nathan Bronson's avatar
      namespace macro in SanitizeThread.cpp · 69b52db2
      Nathan Bronson authored
      Summary:
      Macro name should not use a name that might also be used
      outside folly.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D12901055
      
      fbshipit-source-id: a18bc33fdaabb339aa7539da12b5a82b95e282a7
      69b52db2
    • Orvid King's avatar
      Don't hardcode the value of ECONNREFUSED in AsyncSocketExceptionTest · 838f86a2
      Orvid King authored
      Summary: The value of `ECONNREFUSED` is different on different platforms, so we can't hard-code the value.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D12818063
      
      fbshipit-source-id: 94242a042bef75b391d075a74837b538083d242d
      838f86a2
    • Doron Roberts-Kedes's avatar
      BatonTest: initialize a DeterministicSchedule for tests using DeterministicAtomics · e1b1233a
      Doron Roberts-Kedes authored
      Summary: Using DeterministicAtomic without initializing a DeterministicSchedule doesn't offer determinism, and at the time of the last commit to this test, DeterministicAtomics did not even have atomic operations without a DeterministicSchedule. Initializing a DeterministicSchedule for these tests adds determinism and atomicity to the current DeterministicAtomics. This is will be required once to support atomic history buffers in the future.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D10478718
      
      fbshipit-source-id: f03629ab8683c05eff41eb4886d23d00d42615e8
      e1b1233a
    • Doron Roberts-Kedes's avatar
      Prevent deadlock for DeterministicAtomic in... · 1bab1e54
      Doron Roberts-Kedes authored
      Prevent deadlock for DeterministicAtomic in folly::hazptr_default_domain_helper<DeterministicAtomic>::get()
      
      Summary: Pre-initializing with folly::hazptr_default_domain_helper<DeterministicAtomic>::get() in the test setup avoids deadlock when two threads enter enter __cxa_guard_acquire.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10841885
      
      fbshipit-source-id: 5ed90a4c9a78cb339a37d90b6091870b1dd6a8ae
      1bab1e54
    • Doron Roberts-Kedes's avatar
      DistributedMutexTest: Use std::atomic instead of DeterministicAtomic for tests... · 07ad9800
      Doron Roberts-Kedes authored
      DistributedMutexTest: Use std::atomic instead of DeterministicAtomic for tests that do not initialize a DeterministicSchedule
      
      Summary: operations on DeterministicAtomic may not be atomic without a DeterministicSchedule. Changes planned to DeterministicAtomic to introduce buffering make operations non-atomic with a DeterministicSchedule, but also introduce an assert to explicitly catch this case. This diff changes the tests that will trigger the assert to use std::atomic.
      
      Reviewed By: aary
      
      Differential Revision: D11670861
      
      fbshipit-source-id: 84f4e7874048682728c699c90e987a9a7f15b198
      07ad9800
    • Doron Roberts-Kedes's avatar
      MPMCQueue: Fix anonymous union of T and Atom<T> treatment · d7626a92
      Doron Roberts-Kedes authored
      Summary: The previous code issued stores/loads to the non-atomic anonymous union members from partially specialized Dynamic=true code. This breaks when Atom is a class that doesn't behave like a std::atomic.
      
      Reviewed By: magedm
      
      Differential Revision: D10502987
      
      fbshipit-source-id: 8c4670df98dbc830593b5f0edaaa56e2d8842719
      d7626a92
    • Doron Roberts-Kedes's avatar
      RelaxedConcurrentPriorityQueue: Replace store acq_rel with release · 85cf282f
      Doron Roberts-Kedes authored
      Summary: store with acq_rel is undefined. Found while testing BufferedAtomic.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10509918
      
      fbshipit-source-id: 397381c5f9060be5822bf0977aa0e7ebee1cd836
      85cf282f
    • Doron Roberts-Kedes's avatar
      LifoSem Mem Pool: Avoid deadlock during static initialization · 907063a6
      Doron Roberts-Kedes authored
      Summary:
      There is probably a better solution than this, but wanted to publish this diff to point out the issue.
      
      If DeterministicSchedule has been initialize befored the first invocation of LifoSemRawNode<DeterministicAtomic>::pool(), the thread invoking LifoSemRawNode<DeterminsiticAtomic> will
      enter __cxa_guard_acquire and the DeterministicAtomic constructor.
      
      Implementations of DeterminsticAtomic may be modified to use
      DeterministicSchedule::beforeSharedAccess() in the constructor, which will
      deadlock if a second thread invokes LifoSemRawNode<DeterministicAtomic>::pool()
      before the first thread is rescheduled. For example, BufferedAtomic requires
      shared access during the constructor.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10478693
      
      fbshipit-source-id: eeb09be9ad0fa06c0bb957fff4d56d120b31c6ee
      907063a6
    • Doron Roberts-Kedes's avatar
      IndexedMemPool: Initialize and destroy Atom in slots_ · df9c39d7
      Doron Roberts-Kedes authored
      Summary:
      This is only a bug when Atom != std::atomic (for example when Atom = DeterministicAtomic) since the mmap region is zero-intialized, and the std::atomic constructor does no initialization other than zero initialization. However, this assumption does not hold when Atom != std::atomic.
      
      I'm not super familiar with the details of IndexedMemPool, so perhaps there is a more clever way to initialize and destroy the Atom instances in slots_, but I decided to go with this simple solution since it only modifies the construtor and destructor.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10277293
      
      fbshipit-source-id: 1e70a07963117b04e76f341c5b5148602d4ca48d
      df9c39d7
    • Orvid King's avatar
      Bind with refs rather than pointers · c1585ed8
      Orvid King authored
      Summary: This silences HowToEven's nullability warning.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D12889459
      
      fbshipit-source-id: c460bf3bbb6c4c10df5a2aabbf99689c31bc2d21
      c1585ed8
    • Andrii Grynenko's avatar
      Improve tail call optimization · 0ec1d370
      Andrii Grynenko authored
      Summary:
      Existing tail call optimization implementation only works if the returned future already had callback set by the time the future returned by .then() callback is completed, which makes it's behavior racy.
      This diff takes a slightly different approach by adding a new mode to Core, which makes it forward callback to another Core, once the callback is set.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D12837044
      
      fbshipit-source-id: 13ad822d8dfdcef8bb5a28108c24195ae911550b
      0ec1d370
    • Nathan Bronson's avatar
      move TSAN annotation hook declarations out of header · 20f2b04c
      Nathan Bronson authored
      Summary:
      AnnotateBenignRaceSized is prototyped with a long size arg in
      some third-party libraries and a size_t arg in others.  This diff moves
      folly's prototypes for the TSAN hooks out of a widely-included header
      file so that the incompatible declarations can coexist.  This function
      is declared with C linkage, so the mismatch is not a problem at link time.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D12881785
      
      fbshipit-source-id: af1b7404d9c3d9b728105591c112143d7388f4f9
      20f2b04c
    • Orvid King's avatar
      Support NetworkSocket in FileUtil · 89f3eed9
      Orvid King authored
      Summary: As-per title, these functions need NetworkSocket support.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D12813114
      
      fbshipit-source-id: cc49aa9478d728ff3d1bd4fcb8957083066f7d8a
      89f3eed9
    • Orvid King's avatar
      Add NetworkSocket support to AsyncUDPSocket · 350de5c9
      Orvid King authored
      Summary: More along the path.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10847193
      
      fbshipit-source-id: 5d946855c00752d23c012f2c91f07d276760d371
      350de5c9
    • Orvid King's avatar
      Add NetworkSocket support to EventHandler · b2208566
      Orvid King authored
      Summary: Add overloads to various places and forward the file descriptor versions to the NetworkSocket forms.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10843917
      
      fbshipit-source-id: f1b6958eac2f23dc788e1a3a3557baeed38284f1
      b2208566
    • Orvid King's avatar
      Add NetworkSocket support to SocketAddress · fbbbcf80
      Orvid King authored
      Summary: The first step on the path
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10355407
      
      fbshipit-source-id: 01eec439ae65484e233d5fe94977643d7ab2ed6d
      fbbbcf80
    • Orvid King's avatar
      Back libevent file descriptor transformation with the fd<->socket map · ceebc296
      Orvid King authored
      Summary: Currently it's just leaking file descriptors, stop that by backing it with the map.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10842827
      
      fbshipit-source-id: 434d7463ede1639e0fa2edf0be438aa561b39b16
      ceebc296
    • Chad Austin's avatar
      Add explicit operator=(None) to Optional · 5ea1ed7e
      Chad Austin authored
      Summary:
      In a minor way, this improves folly::Optional's compliance with std::optional. `op = folly::none` used to work by instantiating an empty optional and passing that in. This is more direct.
      
      The existence of this assignment operator is why folly::None must not have a default constructor to support `op = {}` syntax for disengaging the optional.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D12842963
      
      fbshipit-source-id: 757bb66030a667ef0bc1cbe56d150740e712ed45
      5ea1ed7e
    • Orvid King's avatar
      Add a map to convert between sockets and file descriptors · 2adb99bf
      Orvid King authored
      Summary: Lookups through the map are free on platforms where the socket type is a file descriptor, but this lookup is needed to make incremental conversion of Folly APIs viable.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10304788
      
      fbshipit-source-id: 286e206986743f9484f687f6efc0ae7f0e363fd0
      2adb99bf
    • Orvid King's avatar
      Create a handle-type agnostic sockets API and back the Windows socket portability layer with it · d4a7542e
      Orvid King authored
      Summary:
      The end goal will be to have all calls to the sockets APIs go through the agnostic API rather than the current approach, as the current approach causes a limit of ~64k sockets, due to file descriptor limitations on Windows.
      All this diff does for now is create a sockets API that is not backed by file descriptors on Windows.
      This also shifts the sockets portability layer to be backed by these APIs until the sockets portability layer is removed.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10235797
      
      fbshipit-source-id: 1c073231290da48832608f6fec272c3d675bdfd7
      d4a7542e
  3. 01 Nov, 2018 4 commits
    • Chad Austin's avatar
      Remove default constructor for folly::None · 0207d08f
      Chad Austin authored
      Summary: It's never useful to write `folly::None()` or `folly::None{}` instead of using `folly::none`, so disallow the former. This brings `folly::none` closer to `std::nullopt`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D12842421
      
      fbshipit-source-id: 7a3526c8ab16cda8eed1c60650d2cae939c9f96a
      0207d08f
    • Nathan Bronson's avatar
      Back out "[folly/CPortability] allow TSAN hook linkage override at compile time" · 08d12dac
      Nathan Bronson authored
      Summary: Original commit changeset: 10d2921df998
      
      Differential Revision: D12881285
      
      fbshipit-source-id: d61353c3e936543d2e27643e5c0d584079cd2a72
      08d12dac
    • Dan Melnic's avatar
      Fix undefined reference linker error · fd9ac932
      Dan Melnic authored
      Summary: Fix a dbgo-asan undefined reference to 'folly::detail::BufferedStat<folly::TDigest, std::chrono::_V2::steady_clock>::flush()' linker error
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10458537
      
      fbshipit-source-id: 8846440494e83955a43f9d4477885521f34ae7f9
      fd9ac932
    • Kirk Shoop's avatar
      migrate to gtest · d58fe683
      Kirk Shoop authored
      Summary:
      migrated tests
      fixed some bugs introduced while tests were disabled
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10515231
      
      fbshipit-source-id: 34cddb6588c4da9cd05256111bf9626b013dd4fa
      d58fe683
  4. 31 Oct, 2018 4 commits
    • Nathan Bronson's avatar
      allow TSAN hook linkage override at compile time · 20d6c1df
      Nathan Bronson authored
      Summary:
      This diff allows you to override the function attributes for TSAN
      hooks at compile time using -DFOLLY_ATTR_FOR_SANITIZE_THREAD_HOOKS=xyz.
      This is useful for builds that statically link with a library like abseil
      that has its own declarations for the hooks.
      
      Reviewed By: yfeldblum, kennyyu
      
      Differential Revision: D12866286
      
      fbshipit-source-id: 10d2921df998d5dc11f86a5383111d650d31dd8e
      20d6c1df
    • Nathan Bronson's avatar
      heterogeneous string keys by default in F14, with general mechanism · 05975ce4
      Nathan Bronson authored
      Summary:
      This diff adds folly types HeterogeneousAccessLess<T>,
      HeterogeneousAccessEqualTo<T>, and HeterogeneousAccessHash<T> that
      are suitable as the default functor types for containers that support
      heterogeneous access, and it makes those the default for F14 maps and
      sets.  The new functor types will be marked as transparent when possible,
      otherwise they will fall back to the non-transparent std::less<T>,
      std::equal_to<T>, and std::hash<T> respectively.
      
      Heterogeneous lookup is provided for types that are implicitly convertible
      to Range<T const*>, where T is an integral type.  This includes
      std::string, std::string_view (when available), folly::StringPiece,
      folly::MutableStringPiece, std::array, std::vector, folly::small_vector.
      
      HeterogeneousAccessHash<T> will use folly::hasher<folly::Range<
      T::value_type const*>> for hashing when it provides a transparent hash,
      except that for libstdc++ and libc++ we special-case the case hashing
      Range<char const*> to use the same hash function as std::string.
      That makes this diff performance neutral for existing use cases.
      
      Reviewed By: ot
      
      Differential Revision: D8768761
      
      fbshipit-source-id: ded7c86e30479409cf838ac8219241622a4e2332
      05975ce4
    • Jason Rahman's avatar
      Support move-only types in SemiFuture::promise_type · 4ac6c276
      Jason Rahman authored
      Summary:
      The SemiFuture::promise_type class didn't properly handle move only
      types in return_value(). Added overload to handle T&& case properly.
      
      Reviewed By: lewissbaker
      
      Differential Revision: D12837450
      
      fbshipit-source-id: 74edbb2d9de32abc2859f337047ca4e32414de7f
      4ac6c276
    • Yedidya Feldblum's avatar
      Let EventBaseLocal::getOrCreateFn take the callable by value · df8f0965
      Yedidya Feldblum authored
      Summary:
      [Folly] Let EventBaseLocal::getOrCreateFn take the callable by value, rather than by non-const lvalue ref.
      
      This lets temporaries, including lambda expression temporaries, be passed as the callable argument.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D12831069
      
      fbshipit-source-id: 4c61f2cd3fb3eeaab6e7c72d2b0458b657c9d107
      df8f0965
  5. 30 Oct, 2018 7 commits
    • Kyle Nekritz's avatar
      Run OpenSSLCertUtils tests with a polluted OpenSSL error stack. · a81ce979
      Kyle Nekritz authored
      Summary:
      We have had several bugs due to this, running tests with an error in
      the stack by default should help catch them.
      
      Reviewed By: xybu
      
      Differential Revision: D12843909
      
      fbshipit-source-id: 82432b338f24b4a566c6290d39e34cf2e55092ca
      a81ce979
    • Andrii Grynenko's avatar
      Fix tail call optimization · a5ef29a1
      Andrii Grynenko authored
      Summary: The is_same check was unnecessary. The type of the future which .then() is called on, doesn't matter because it's core is not participating in the callback stealing.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D12836654
      
      fbshipit-source-id: 8dcf3f0a4e44e01a1efda9534edafce9a591e9cf
      a5ef29a1
    • Kyle Nekritz's avatar
      Clear error stack in readCertsFromBuffer. · 3a7f777a
      Kyle Nekritz authored
      Summary:
      Otherwise this function throws if there was an error left in the
      stack.
      
      Reviewed By: AjanthanAsogamoorthy
      
      Differential Revision: D12840871
      
      fbshipit-source-id: 233c10e0448c937a68bf8f09d24ccaa12fcc57a4
      3a7f777a
    • Chad Austin's avatar
      Disallow construction of std::optional from folly::none · c36c506a
      Chad Austin authored
      Summary:
      I spent a day trying to convert some code from folly::Optional to
      std::optional. One hour of that was making the necessary syntax
      changes. The rest was diagnosing why certain bits of code broke. The
      reason turned out to be that `folly::Optional` allowed construction
      from nullptr and that `std::optional<bool>{folly::none}` would result
      in `std::make_optional(false)`, not `std::nullopt`.
      
      Instead of implementing folly::none with a pointer-to-member, copy the
      implementation of the upcoming std::nullopt.
      
      As teams switch to C++17, this should smooth the migration.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10475780
      
      fbshipit-source-id: 3a072b5e7e95209721d871361f5a24e3e30472cd
      c36c506a
    • Lee Howes's avatar
      Upgrade error level for deprecation attributes · edcd66e1
      Lee Howes authored
      Summary: Make deprecation messages firmer.
      
      Reviewed By: WillerZ
      
      Differential Revision: D10855134
      
      fbshipit-source-id: 181bc0ed6d5ccaefdca22264182e8fbe47c1a9b9
      edcd66e1
    • Aaryaman Sagar's avatar
      Initializer list constructor and emplace make_optional versions · 6eb37d26
      Aaryaman Sagar authored
      Summary: Add a missing initializer list constructor and variadic argument emplacing make_optional variants.
      
      Reviewed By: yfeldblum, ot
      
      Differential Revision: D8918866
      
      fbshipit-source-id: a343602f91b5e0ee0b5c293ca929a699b6104996
      6eb37d26
    • Aaryaman Sagar's avatar
      Remove return value check in folly::chrono::coarse_monotonic_clock · cd1ab8b9
      Aaryaman Sagar authored
      Summary: This shaves off 0.5ns
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10320634
      
      fbshipit-source-id: 1a790df14b128b3b02c810ec45ba48c2ce5e4612
      cd1ab8b9
  6. 28 Oct, 2018 1 commit
    • Jason Rahman's avatar
      Fix Uninitialized Try exception when co_awaiting on fulfilled futures. · e899e1af
      Jason Rahman authored
      Summary:
      FutureAwaitable currently does not properly handle the case where an
      already fulfilled future is awaited on. In particular, await_ready() is based
      on the value of future_.isReady(), while await_resume() pulls the value from
      result_, regardless of whether or not result_ has been correctly initialized by
      the callback registered in await_suspend. When an already fulfilled
      future is awaited on, await_ready() will return true immediately, and await_suspend() will
      be bypassed and await_resume() called immediately, throwing an exception since result_ hasn't been initialized.
      
      Reviewed By: lewissbaker
      
      Differential Revision: D12816274
      
      fbshipit-source-id: f5f697e433c1621f829af6f5509d08bac2229ddb
      e899e1af
  7. 27 Oct, 2018 3 commits
    • Orvid King's avatar
      Use the right type for values · d2c2e40c
      Orvid King authored
      Summary: MSVC was complaining very loudly about these being implicitly truncated to `int`s in the initialization of OptionsMap, so declare them as `int`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10861911
      
      fbshipit-source-id: 0d5c52fe4b5e59c5e101546093a13849fe3b2a7a
      d2c2e40c
    • Orvid King's avatar
      Guard dlfcn include correctly · 7fb6c54e
      Orvid King authored
      Summary: It doesn't exist on Windows, so only include it when it's acutally used.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D10861997
      
      fbshipit-source-id: 04156a09f2fab83ae3b958c1cbcd41c347d5f9e8
      7fb6c54e
    • Andrew Gallagher's avatar
      Back out "folly/memory/Malloc.h: include a few more JEMalloc macro definitions" · 76cf8b58
      Andrew Gallagher authored
      Summary:
      This was actually just incorrectly masking a inconsistency between
      `folly/memory/Malloc.h` and `<jemalloc/jemalloc.h>` and the proper fix is
      D10866789.
      
      Reviewed By: elsteveogrande
      
      Differential Revision: D12207144
      
      fbshipit-source-id: 2ecf818c04c8e124bcfe96433a7269b3deadb502
      76cf8b58