1. 22 Dec, 2017 2 commits
  2. 21 Dec, 2017 1 commit
    • Andrii Nakryiko's avatar
      Fix crashing on corrupted ELF binaries with invalid offsets in ELF header. · 5d64a503
      Andrii Nakryiko authored
      Summary:
      There are cases where ELF binaries are running fine, but have slightly
      corrupted ELF headers, e.g., with section headers offset pointing beyond boundaries
      of file. I'm guessing this is due to running strip or objdump with either some
      particular combination of flags or some due to buggy version of those tools. This
      change prevents from crashing on such files.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6616027
      
      fbshipit-source-id: 8cb3ac4475a51d1f1045c395977a6a77fbefffb2
      5d64a503
  3. 20 Dec, 2017 6 commits
    • Chad Austin's avatar
      test that the value remains alive even if the .then callback takes no arguments · 9df5dacf
      Chad Austin authored
      Summary:
      It was not clear to me, if a callback takes no arguments, the
      underlying value is guaranteed to be alive during the execution of the
      callback, so I wrote these tests.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6594921
      
      fbshipit-source-id: 6a658afc1bf4d29eaa9c62269ddc21c7f897ad01
      9df5dacf
    • Yedidya Feldblum's avatar
      Kill FOLLY_ALIGNED etc · 8091d719
      Yedidya Feldblum authored
      Summary:
      [Folly] Kill `FOLLY_ALIGNED` etc.
      
      `alignas` is standardized as of C++11. Let us just use that.
      
      Replace:
      * `FOLLY_ALIGNED` with `alignas`
      * `FOLLY_ALIGNED_MAX` with `alignas(folly::max_align_v)`
      * `FOLLY_ALIGN_TO_AVOID_FALSE_SHARING` with `alignas(folly::hardware_destructive_interference_size)`
      
      Because where `alignas` may be placed is more restrictive than where attributes may be placed, we also need to move these directives in some cases on top of doing the replacement.
      
      Reviewed By: Orvid
      
      Differential Revision: D6555167
      
      fbshipit-source-id: 4b05b570bace3f8c0fe810b6dd58781dd45757f4
      8091d719
    • Yedidya Feldblum's avatar
      Fix Build: propagate_const under GCC · 1166fe0e
      Yedidya Feldblum authored
      Summary: [Folly] Fix Build: `propagate_const` under GCC.
      
      Reviewed By: aary
      
      Differential Revision: D6609722
      
      fbshipit-source-id: 47d8b0f2d54e0e5834383ea64c93af30927c921d
      1166fe0e
    • Zheng Yan's avatar
      Add readWithPriority to PriorityMPMCQueue · 67300dac
      Zheng Yan authored
      Summary: Add readWithPriority to PriorityMPMCQueue
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6606604
      
      fbshipit-source-id: 07382e3c6d0f53a8727c059410c0577cf0aac82c
      67300dac
    • Yedidya Feldblum's avatar
      Add hardware_destructive_interference_size · 5ad17f07
      Yedidya Feldblum authored
      Summary:
      [Folly] Add `hardware_destructive_interference_size` and `hardware_constructive_interference_size` to `folly/lang/Align.h`.
      
      As backports from C++17. Which may require keeping, depending on how stanard libraries choose to implement these.
      
      And replace `CacheLocality::kFalseSharingRange` with `hardware_destructive_interference_size`.
      
      Reviewed By: ot
      
      Differential Revision: D6554817
      
      fbshipit-source-id: bff49f5ca8b01d38fa806076f99201355df76cd9
      5ad17f07
    • Yedidya Feldblum's avatar
      propagate_const · d1ef992f
      Yedidya Feldblum authored
      Summary: [Folly] `propagate_const`, backported from C++ Library Fundamentals TS v2.
      
      Reviewed By: ericniebler
      
      Differential Revision: D6589681
      
      fbshipit-source-id: cdc8981d17938b99afe60e2baefff7deb5316612
      d1ef992f
  4. 19 Dec, 2017 5 commits
    • Dave Watson's avatar
      Fix erase in Iterate (2) · a807bde9
      Dave Watson authored
      Summary:
      Previously D6579707.
      
      Correctly advance to next item if we erase the current element.  Corner cases were slightly off if we were at the end of a hash chain.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6603518
      
      fbshipit-source-id: acb959e5bcd5da1c3df642b75985d464fdd3b23d
      a807bde9
    • Dave Watson's avatar
      Fix ThreadLocal races · 74502e3c
      Dave Watson authored
      Summary:
      I misread the ThreadLocal docs, thread destruction functions do *not* grab the accessAllTHreads_ lock
      unless you use *strict* mode, and even then, it is only a read lock.
      
      Easy enough to make the thread-destruction global bits to be atomic / use folly::Synchronized.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6592905
      
      fbshipit-source-id: 4ae600dff4c8c04751483a452ca7c07ef3f26380
      74502e3c
    • Yedidya Feldblum's avatar
      Switch the Baton template params · 58399f25
      Yedidya Feldblum authored
      Summary: [Folly] Switch the `Baton` template params for consistency with `SaturatingSemaphore`.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D6591060
      
      fbshipit-source-id: 44d6243d3185d95364a27e497216cc02fb3bc2e8
      58399f25
    • Dustin Pho's avatar
      Secure RNG utilities · a72e7903
      Dustin Pho authored
      Summary: Adding secure RNG utility functions (rand32, rand64, oneIn, randDouble01, randDouble).
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6551975
      
      fbshipit-source-id: 720d138de1329669b1a15eb3e9cb3fe91ce982a4
      a72e7903
    • Yedidya Feldblum's avatar
      Baton::ready, a const variant of try_wait · 7fc3f917
      Yedidya Feldblum authored
      Summary: [Folly] `Baton::ready`, a `const` variant of `try_wait`.
      
      Reviewed By: djwatson
      
      Differential Revision: D6508064
      
      fbshipit-source-id: ba458577574ba58165408a93238da7eb09adf1e6
      7fc3f917
  5. 18 Dec, 2017 2 commits
    • Giuseppe Ottaviano's avatar
      Make global executors shutdown-safe · cfc602df
      Giuseppe Ottaviano authored
      Summary:
      The `get*Executor()` APIs don't check whether the singletons
      haven't been destroyed already. Add a check and allow to return
      `nullptr` during shutdown.
      
      Also do a general clean up of the code, there was no reason to use
      three independent singletons (non-atomically destroyed) for each
      executor.
      
      Reviewed By: philippv, luciang
      
      Differential Revision: D6589486
      
      fbshipit-source-id: 20fb835db7e446bd811bbd6d5ddbc41db9e98b54
      cfc602df
    • Christopher Dykes's avatar
      Remove the folly/Assume.h shim · 3975849d
      Christopher Dykes authored
      Summary: The shim existed so that hhvm-third-party could be updated, and it has been, so it's time to remove the shim.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6590439
      
      fbshipit-source-id: 3e1b039c1df6cf1e74102f7b7b26aa90fae31ec0
      3975849d
  6. 17 Dec, 2017 1 commit
  7. 16 Dec, 2017 5 commits
    • Maged Michael's avatar
      UnboundedQueue: Change try_dequeue variants to fail only if the queue is empty · f4d97dc6
      Maged Michael authored
      Summary:
      The current semantics of try_dequeue variants can cause problems in cases where based on external dependencies the consumer is guaranteed that the queue is not empty and depends on the success of try_dequeue. See https://github.com/facebook/wangle/commit/abd07a06cae09efcd4347a9a019d59ae8a013c3f
      
      This diff changes the semantics so that try_dequeue operations fail only if the queue is empty.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6586156
      
      fbshipit-source-id: 25d6085e28d3e24034ecf6a8bafab51c95464b01
      f4d97dc6
    • Maged Michael's avatar
      UnboundedQueue: Fix advanceHead · 124efa23
      Maged Michael authored
      Summary:
      Without the fix multiple consumers may update head concurrently and cause it to lag. If this persists until the destruction time of the queue, some segments may be incorrectly retired twice.
      
      The fix is to wait for head to advance to the current segment first before advancing head to the next segment.
      
      Reviewed By: djwatson
      
      Differential Revision: D6588135
      
      fbshipit-source-id: 3e916441bff5ad3f27de418601990c59a0b89bc2
      124efa23
    • Yedidya Feldblum's avatar
      Group the fields of UnboundedQueue · ca3dd9ce
      Yedidya Feldblum authored
      Summary:
      [Folly] Group the fields of `UnboundedQueue`.
      
      Into helper structures which are organized by, and aligned by, access.
      
      This is all compiled away and has no runtime cost.
      
      Reviewed By: magedm
      
      Differential Revision: D6555031
      
      fbshipit-source-id: 94424747bf76a0a9a2bd59b6a94749efb391d6a7
      ca3dd9ce
    • Maged Michael's avatar
      Fix comments in UnboundedQueue and DynamicBoundedQueue · a123a11e
      Maged Michael authored
      Summary: Fix typos and wording in comments.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6584559
      
      fbshipit-source-id: b4b72f6c25c9f9e6fb3f2fbee69eea4a39b5c004
      a123a11e
    • Yanbo Xu's avatar
      Revert D6579707: [folly/ConcurrentHashMap] Fix erase in Iterate · b5750c50
      Yanbo Xu authored
      Summary:
      This reverts commit a45f47a53e106d22daa9cf57be6c40c4f6a430d9
      
      bypass-lint
      
      Differential Revision: D6579707
      
      fbshipit-source-id: 6f6c35de5e05f8cf37491471e1ae1272290fe61b
      b5750c50
  8. 15 Dec, 2017 5 commits
    • Keith Daigle's avatar
      Fix PicoSpinLock on aarch64 · 7a45c3e0
      Keith Daigle authored
      Summary:
      Found that building folly on aarch64 gave errors with
      picospinlock.  Looked and found that MSVC used casts
      so I figured I'd try that
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6504689
      
      fbshipit-source-id: 9565bae5ffab485da407b8609be92ef7db10ab72
      7a45c3e0
    • Yanbo Xu's avatar
      Fix erase in Iterate · baa03294
      Yanbo Xu authored
      Summary:
      The iterator returned from erase api could skip nodes. The fix is to
      initialize the returned iterator with right value.
      
      Reviewed By: djwatson
      
      Differential Revision: D6579707
      
      fbshipit-source-id: a45f47a53e106d22daa9cf57be6c40c4f6a430d9
      baa03294
    • Yedidya Feldblum's avatar
      Fix folly::max_align_v for Clang on ARMv7 · 8b3a565d
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix `folly::max_align_v` for Clang on ARMv7.
      
      There is some problem with computing the correct result of `alignof` for a compound `union` POD type, because why wouldn't there be. The result *should* just be the max of the `alignof` of the type of each field if each field is default aligned - but not on some platforms! So we must compute the max directly.
      
      Reviewed By: mzlee, Orvid
      
      Differential Revision: D6573548
      
      fbshipit-source-id: 512a255fda64795104d71fde14372befa3bf41e4
      8b3a565d
    • Yedidya Feldblum's avatar
      Let Baton methods be noexcept · 6ae2206d
      Yedidya Feldblum authored
      Summary: [Folly] Let `Baton` methods be `noexcept`.
      
      Reviewed By: djwatson
      
      Differential Revision: D6508057
      
      fbshipit-source-id: 2138a228d8291e79e9368cb77b0f63f4412524dc
      6ae2206d
    • Dan Melnic's avatar
      Fix zerocopy AsyncSocket memory leaks · 23e45679
      Dan Melnic authored
      Summary:
      We currently leak ptr entries due to a missing map erase call in AsyncSocket::releaseZeroCopyBuf.
      Also addZeroCopyBuf called when the bytesWritten == 0 will cause and extra id to be allocated. This will delay the deletion of the last IOBuf sent via zerocopy. The number of buffers can accumulate over time if the same bytesWritten == 0 situation is encountered.
      Found when running the nbd-server zero downtime upgrade during heavy fio traffic.
      Add an AsyncSocket::processZeroCopyWriteInProgress so we can drain the zerocopy msg error queue even after we set the ReadCallback to nullptr.
      
      Reviewed By: djwatson
      
      Differential Revision: D6552982
      
      fbshipit-source-id: 3d2fdca84ec3b5fc46c3bed06c0c9ede66ed565a
      23e45679
  9. 14 Dec, 2017 8 commits
    • Chen Shen's avatar
      Fix xlog docs · f5882bb6
      Chen Shen authored
      Summary: When I was investigating the difference between glog/xlog I encountered this.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6572117
      
      fbshipit-source-id: 4130deb6cfed7cfb7d2433cdab292481beb2469f
      f5882bb6
    • Yedidya Feldblum's avatar
      Use explicit memory order in Baton::post · c5a4f4c8
      Yedidya Feldblum authored
      Summary: [Folly] Use explicit memory order in `Baton::post`.
      
      Reviewed By: djwatson
      
      Differential Revision: D6502268
      
      fbshipit-source-id: a379ea711f165e3645ac2127a49824f46225b80a
      c5a4f4c8
    • Kyle Nekritz's avatar
      Move security protocol and application protocol APIs to AsyncTransport. · 5acf7b92
      Kyle Nekritz authored
      Summary: They belong here rather than AsyncTransportWrapper.
      
      Reviewed By: siyengar
      
      Differential Revision: D6568209
      
      fbshipit-source-id: 0856dba0b2d527ae68d33942b28e2c485a5b1f46
      5acf7b92
    • Maged Michael's avatar
      Dynamic Bounded Queue · 17c08956
      Maged Michael authored
      Summary:
      DynamicBoundedQueue supports:
      - Dynamic memory usage that grows and shrink in proportion to the number of elements in the queue.
      - Adjustable capacity that helps throttle pathological cases of producer-consumer imbalance that may lead to excessive memory usage.
      - The adjustable capacity can also help prevent deadlock by allowing users to temporarily increase capacity substantially to guarantee accommodating producer requests that cannot wait.
      - SPSC, SPMC, MPSC, MPMC variants.
      - Blocking and spinning-only variants.
      - Inter-operable non-waiting, timed until, timed for, and waiting variants of producer and consumer operations.
      - Optional variable element weights.
      
      Reviewed By: djwatson
      
      Differential Revision: D6462123
      
      fbshipit-source-id: 5c7a7d88c3fa273211702af9ff78f6302afd2276
      17c08956
    • Maged Michael's avatar
      UnboundedQueue: Use alignas instead of FOLLY_ALIGNED · d5b67c25
      Maged Michael authored
      Summary: Use alignas instead of FOLLY_ALIGNED
      
      Reviewed By: Orvid
      
      Differential Revision: D6554984
      
      fbshipit-source-id: 5b11ac387faa137aa8dd0c35b6e9bb999cf0bf2d
      d5b67c25
    • Yedidya Feldblum's avatar
      Fix AsyncSocketTest.WriteErrorCallbackBytesWritten · 82d8337f
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix `AsyncSocketTest.WriteErrorCallbackBytesWritten`.
      
      Thanks to congestion, especially when the tests are run concurrently, the expectations in the test were too restrictive.
      
      If only 20KB are read, it is possible that only 20KB are acknowledged. The expectation was that if 20KB are read and the recv buffer and send buffer are both 8KB and 24KB are written then all 24KB are acknowledged, but congestion control disagrees.
      
      It is possible that any number of bytes are written to the send buffer, from 28KB up to 40KB. And we have to explicitly wait for 28KB to be written even to know that (otherwise we only know that 20KB are written).
      
      Differential Revision: D6550804
      
      fbshipit-source-id: 100d086972c1526b909da0dbb6e609c144d7b17b
      82d8337f
    • Yedidya Feldblum's avatar
      constexpr_ceil · 8fba851f
      Yedidya Feldblum authored
      Summary: [Folly] `constexpr_ceil`, an integral rounding-up util.
      
      Reviewed By: Orvid
      
      Differential Revision: D6558042
      
      fbshipit-source-id: 6b42add9bf2e3605baf71391130c2a2c88cc4385
      8fba851f
    • Yedidya Feldblum's avatar
      Move max_align_v and max_align_t to folly/lang/Align.h · 9b2b633c
      Yedidya Feldblum authored
      Summary:
      [Folly] Move `max_align_v` and `max_align_t` to `folly/lang/Align.h`.
      
      And drop the macro `FOLLY_ALIGNED_MAX` - just use `alignas(max_align_v)` instead.
      
      Reviewed By: Orvid
      
      Differential Revision: D6554677
      
      fbshipit-source-id: cacb335b141623506a41e95e0740613374279c6f
      9b2b633c
  10. 13 Dec, 2017 5 commits
    • Yedidya Feldblum's avatar
      Remove unused #include <string.h> from folly/Portability.h · 0a1444e7
      Yedidya Feldblum authored
      Summary: [Folly] Remove unused `#include <string.h>` from `folly/Portability.h`.
      
      Reviewed By: Orvid
      
      Differential Revision: D6557374
      
      fbshipit-source-id: 369ef0b622dc057e882ed0f4ad25b47fa3f05100
      0a1444e7
    • Christopher Dykes's avatar
      Explicitly refer to the std::chrono namespace to avoid conflicts with the folly::chrono namespace · 4cbf7a64
      Christopher Dykes authored
      Summary:
      This is a hard requirement due to an upcoming change in Folly.
      
      The codemod was only run on files that referenced the `std::chrono` namespace with an unqualified `chrono` and also used both the `std` and `folly` namespaces.
      ```
      fbgr -sl "[^:]chrono::" | xargs grep -l "using namespace std;" | xargs grep -l "using namespace folly;" | xargs sed -r -i 's/([^:])chrono::([a-z])/\1std::chrono::\2/g'
      ```
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6547864
      
      fbshipit-source-id: 4a8230d311edbaa173722a09b2773e8d053fae7e
      4cbf7a64
    • RcRonco's avatar
      typo in io/Cursor.h · 9b471821
      RcRonco authored
      Summary: Closes https://github.com/facebook/folly/pull/721
      
      Differential Revision: D6558163
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: ed03aa92b54c61f9980a4759da29910aa77d5db6
      9b471821
    • Dave Watson's avatar
      RCU · f885995c
      Dave Watson authored
      Summary: This adds an RCU implementation, matching http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0461r1.pdf as closely as pratical.  This implementation does not require thread registration or quiescence.
      
      Reviewed By: magedm
      
      Differential Revision: D6330631
      
      fbshipit-source-id: 2c729f3a4c0f151cde5d9a599ecd2a2c20c7da55
      f885995c
    • Adam Simpkins's avatar
      logging: minor clean up in Logger.h · 6283c759
      Adam Simpkins authored
      Summary:
      Update the comment describing the Logger class, and remove a `clang-format off`
      since recent versions of `clang-format` appear to do a good job formatting this
      macro.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D6525996
      
      fbshipit-source-id: 6abbb3740afb53feb2418ca890cd78af1eb5f7a2
      6283c759