1. 22 Aug, 2020 2 commits
    • Michael Park's avatar
      Add `std::variant` support for `folly::variant_match`. · a5683e13
      Michael Park authored
      Summary: This patch adds support for `std::variant` to `folly::variant_match` but without including `<variant>`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23196572
      
      fbshipit-source-id: 9d5b519958b04c13cc024d393247c73cec00ac67
      a5683e13
    • Misha Shneerson's avatar
      Do not capture RCTX in HHWheelTimer's underlying AsyncTimeout · e72f5c7b
      Misha Shneerson authored
      Summary:
      We should only be capturing `folly::RequestContext` in HHWheelTimer's callback
      objects (already  happens). And avoid capturing it in underlying AsyncTimeout.
      
      Notice that `AsyncTimeout::scheduleTimeout`/`scheduleTimeoutHighRes` APIs capture
      current `folly::RequestContext` and `AsyncTimeout::cancelTimeout`
      releases the captured `folly::RequestContext`
      
      Now, the way HHWheelTimer works, it re-uses one instance of AsyncTimeout for
      multiple timeouts. This opens up possibility for leaking lifetime of RCTX.
      Imagine first  request A and then B schedule timeouts using same HHWheelTimer
      instnace. A's RCTX is captured by underlying AsyncTimeout. Next, request A is
      complete and we need to cancel its timeout. Notice, however that A's RCTX will
      not be destroyed as long as B is still running. That's the lifetime management
      leak.
      
      Reviewed By: jordalgo, andriigrynenko
      
      Differential Revision: D23260733
      
      fbshipit-source-id: 0bdf79db40d34d6682e89e87ce30811ffccc8cbf
      e72f5c7b
  2. 21 Aug, 2020 2 commits
  3. 20 Aug, 2020 5 commits
    • Shai Szulanski's avatar
      Add deduction guide to co_result · 694c1cbc
      Shai Szulanski authored
      Reviewed By: yfeldblum, lewissbaker
      
      Differential Revision: D23240860
      
      fbshipit-source-id: 74aab6151c9c44159a2d3fc4e041b475b69e29e7
      694c1cbc
    • Dan Melnic's avatar
      Do not call scheduleImmediateRead() if the EVB has changed · c4c78b82
      Dan Melnic authored
      Summary: Do not call scheduleImmediateRead() if the EVB has changed
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23234912
      
      fbshipit-source-id: 8394700a53b4e2fa925519271c1c27fc0ce11a85
      c4c78b82
    • Nanshu Chen's avatar
      refactor Enum code generation · ad89a017
      Nanshu Chen authored
      Summary:
      Changed the way how enums generated in thrift-py3:
      
      1. Use C++ map to store name to unique Enum Python instances cache
      2. Dynamically find instances from cache (or create one and add to cache) instead of populating all instances at module load time
      3. use `__getattr__` and `__getitem__` instead of code-gen all the getters
      
      Reviewed By: asp2insp
      
      Differential Revision: D23182622
      
      fbshipit-source-id: 75baef997ee2d604b4ef7606f282cfc3306208ac
      ad89a017
    • Andrew Gallagher's avatar
      Remove self-include · 1ceb5acb
      Andrew Gallagher authored
      Reviewed By: yfeldblum
      
      Differential Revision: D23223918
      
      fbshipit-source-id: 72fb70ccabb57229298515f55334807ad2dfff36
      1ceb5acb
    • Shrikrishna Khare's avatar
      SAI API 1.6.3 · ecc740ba
      Shrikrishna Khare authored
      Summary: As titled.
      
      Differential Revision: D23216535
      
      fbshipit-source-id: 4d278cd1f5d4c661eddda265d92f51d391192404
      ecc740ba
  4. 19 Aug, 2020 3 commits
    • Yedidya Feldblum's avatar
      Re-port memrchr · c8972cd5
      Yedidya Feldblum authored
      Summary:
      [Folly] Re-port memrchr, avoiding build-system detection.
      
      Proper detection at build-system time is challenging.
      * Some platforms do not define `memrchr`.
      * Some platforms define it as a C function.
      * Some platforms define it as a pair of C++ functions.
      
      Proper porting requires proper build-system detection.
      
      Rather than going down that rabbit-hole, we can wrap `memrchr` and do compile-time detection using SFINAE.
      
      This change adds a new strategy. A subsequent change may remove the old strategy.
      
      Reviewed By: Orvid
      
      Differential Revision: D22125127
      
      fbshipit-source-id: 2da7cca571de335b2cff43ff7846ab04d90136ef
      c8972cd5
    • Misha Shneerson's avatar
      priority can be a negative int8_t · 190ff15c
      Misha Shneerson authored
      Reviewed By: yfeldblum
      
      Differential Revision: D23178843
      
      fbshipit-source-id: d9fade6f7a5f8472bffb7a40d285eaf7646ac0e8
      190ff15c
    • Yedidya Feldblum's avatar
      Minimize conditional compilation in AsyncUDPSocket · be66f73c
      Yedidya Feldblum authored
      Summary: [Folly] Minimize conditional compilation in `AsyncUDPSocket`.
      
      Differential Revision: D23172282
      
      fbshipit-source-id: 6ead5cf2232b9db0f709080666262ccc4b5984da
      be66f73c
  5. 18 Aug, 2020 5 commits
    • Michael Park's avatar
      Removed out-dated notes from `Futures.md`. · 16a70848
      Michael Park authored
      Summary:
      The examples showing `thenValue(executor, ...)` is outdated since the executor-taking form of `then` have been `delete`d.
      
      The example showing racy execution of continuations of `Future`s is no longer relevant. It used to be a valid example when the `Future`s used to be "activated" on destruction, but they no longer have this behavior.
      
      Fixes #1422.
      
      Reviewed By: LeeHowes
      
      Differential Revision: D23181958
      
      fbshipit-source-id: 46d2bedd4fef344734d3eb15eb295b9a98969665
      16a70848
    • Jon Janzen's avatar
      Add github action to auto-release TagIt tags · cad3b5cf
      Jon Janzen authored
      Summary:
      This came from a [request from Fred Emmott](https://fb.workplace.com/groups/osssupport/permalink/4116491528399431/), but also is something we should do due to the GitHub UI redesign:
      
      Nowadays on GitHub, tags are not shown in the sidebar (just the count) and instead GitHub Releases are prioritized and the most recent *release* is shown.
      
      Secondly, the Source Code zip archives for tags/releases are created on-the-fly on GitHub. This can cause problems for downstream projects that need consistent content hashes of the archive for security/reproducability reasons. This action also creates its own archives (zip and tar.gz) and attaches them to the release.
      
      Reviewed By: fredemmott
      
      Differential Revision: D23167073
      
      fbshipit-source-id: 463e9d93a2c4af260ac3c4dbc1ceab7894add714
      cad3b5cf
    • Koray Polat's avatar
      Add option to run tests without Testpilot even when it's available · cd9669af
      Koray Polat authored
      Summary:
      - Added a commandline flag to ignore testpilot even when it's available
      - Fixed an oversight that caused getdeps to return 0 even if ctest tests have failed.
      
      Reviewed By: wez
      
      Differential Revision: D23161362
      
      fbshipit-source-id: 1ed97c481315e2b39f1128680386390930194970
      cd9669af
    • Andrew Smith's avatar
      Change AsyncPipe to accept an optional onClosed callback · a6de480b
      Andrew Smith authored
      Summary: This diff allows the user to specify an optional onClosed callback for AsyncPipe, analogous to the callback accepted by thrift's ServerStreamPublisher.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D23024437
      
      fbshipit-source-id: 546cc7e0ea1099cadfa085f5dd2fb9085b88f695
      a6de480b
    • Chad Austin's avatar
      only use symbolizer if libunwind is found · 5e4f665c
      Chad Austin authored
      Summary: folly/experimental/symbolizer requires libunwind. Do not enable it unless libunwind is available.
      
      Reviewed By: yfeldblum, luciang
      
      Differential Revision: D22964401
      
      fbshipit-source-id: d71991346927fbf18167637770b2143c03b16476
      5e4f665c
  6. 17 Aug, 2020 9 commits
    • Shai Szulanski's avatar
      Make task -> semiFuture -> task preserve void type · c452ce03
      Shai Szulanski authored
      Summary:
      Task -> semi has to lift void to unit because semifutures don't support void.
      Semi -> task (via co_await) does not drop unit. It probably should because roundtrip properties are nice, but on the off chance someone actually wants to pass a unit around that would become impossible.
      But for the result type the Try<void> is already implicitly convertible to Try<Unit>, as those types aren't meaningfully different (and not at all in this context where empty Try is not possible). So we can return Try<void> from co_awaitTry instead of Try<Unit>, and then generic code that wants `co_yield co_result(co_await co_awaitTry(SemiFuture<T|Unit>))` from a `Task<T|void>` will work.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D23004090
      
      fbshipit-source-id: 5254e2930ac02952abd92fd2856c2a7d3e952e20
      c452ce03
    • Perry Randall's avatar
      Revert D22499183: refactor Enum code generation · 15dd0f0c
      Perry Randall authored
      Differential Revision:
      D22499183 (https://github.com/facebook/folly/commit/24364356023d04f966a0ef6fc7536363932bdc82)
      
      Original commit changeset: b2af8d94024c
      
      fbshipit-source-id: a6bd56cdb4d4b73618a9374528371c5b18a0df10
      15dd0f0c
    • Chad Austin's avatar
      Require fbstring be used with std::allocator · efedce93
      Chad Austin authored
      Summary:
      basic_fbstring provides an allocator template paramater for
      compatibility with basic_string, but ignores it. Assert at compile
      time that a custom allocator isn't used.
      
      This would have prevented the regression introduced in D22970418 (https://github.com/facebook/folly/commit/abb4ece62120ff32aaf28dc4bbfdc6a2f2b41f78) and
      fixed in D23035304 (https://github.com/facebook/folly/commit/8b650246220717f27046593b5819fbaa60427bcb).
      
      Reviewed By: luciang
      
      Differential Revision: D23144806
      
      fbshipit-source-id: c541f274e97736b9408651a66088bcbb78025539
      efedce93
    • Curtis Li's avatar
      Fix some -Wdocumentation errors · 63dc5615
      Curtis Li authored
      Summary:
      Fixes a few documentation errors that get surfaced when compiling with the -Wdocumentation flag.
      
      Full explanation of errors with examples here:
      https://clang.llvm.org/docs/DiagnosticsReference.html#wdocumentation
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23119100
      
      fbshipit-source-id: 4e84f624e4d81914b78211af4860540498f8110c
      63dc5615
    • Mike Kolupaev's avatar
      Fix coro::UnboundedQueue::try_dequeue · 49b1f90b
      Mike Kolupaev authored
      Summary: try_dequeue() used to consume from the queue but not from the semaphore, causing the two to diverge and breaking subsequent dequeue() calls.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23160324
      
      fbshipit-source-id: f709733d984f51abc53595d38dbef3daffbfa6d9
      49b1f90b
    • Yedidya Feldblum's avatar
      Move DeterministicSchedule TLState to the source · 481a93de
      Yedidya Feldblum authored
      Summary: [Folly] Move `DeterministicSchedule` helper alias `TLState` to the source, and outline all uses into the source.
      
      Reviewed By: nbronson, luciang
      
      Differential Revision: D23157071
      
      fbshipit-source-id: 957576a61a796f46da781e02419a1229e681d4c1
      481a93de
    • Jonathan Kim's avatar
      Update folly's source of truth to xplat · 0b3d9d21
      Jonathan Kim authored
      Reviewed By: mzlee
      
      Differential Revision: D23066827
      
      fbshipit-source-id: 6362acb7a6680a24871859d7874a9caec0a1538e
      0b3d9d21
    • Nanshu Chen's avatar
      refactor Enum code generation · 24364356
      Nanshu Chen authored
      Summary:
      Changed the way how enums generated in thrift-py3:
      
      1. Use C++ map to store name to unique Enum Python instances cache
      2. Dynamically find instances from cache (or create one and add to cache) instead of populating all instances at module load time
      3. use `__getattr__` and `__getitem__` instead of code-gen all the getters
      
      Reviewed By: yfeldblum
      
      Differential Revision: D22499183
      
      fbshipit-source-id: b2af8d94024c3591c3d7faaa15cbd026a134cc78
      24364356
    • Yedidya Feldblum's avatar
      Remove wrong use of errno in AsyncUDPSocket · 72530db7
      Yedidya Feldblum authored
      Summary: [Folly] Remove wrong use of `errno` in `AsyncUDPSocket`.
      
      Reviewed By: markisaa
      
      Differential Revision: D23153435
      
      fbshipit-source-id: f567aa97ebe243ff5b6ad99e300212df290800bb
      72530db7
  7. 16 Aug, 2020 3 commits
    • Robin Cheng's avatar
      Fix a race condition in the thread exit/join code in DeterministicSchedule. · 013b287c
      Robin Cheng authored
      Summary:
      Previously, there was a race between exitingSems_[...] = tls.sem (in beforeThreadExit) and exitingSems_[...].post() (in joinAll). The race exists because exitingSems_ is a map that is not protected by the "shared access" synchronization mechanism used by DeterministicSchedule (i.e. it does not sit between a beforeSharedAccess and afterSharedAccess pair). Specifically, the main thread can be reading exitingSems_ while a child thread is writing to it.
      
      This diff fixes that: after all threads are ready to exit (this part isn't changed), we first wait for the joiner thread itself to be scheduled, and then, it will post the semaphore to wake up the child thread to run its thread-local destructors, and at the same time call .join() on the child. All this runs in a "critical section" between beforeSharedAccess and afterSharedAccess in the joiner thread.
      
      For clarity also changed the child thread to use descheduleCurrentThread, and to make the DeterministicSchedule destructor no longer call beforeThreadExit since it makes little sense.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23119075
      
      fbshipit-source-id: 22bc6ffd9a9d888cc09bdee066dcac7f05b29fa7
      013b287c
    • Yedidya Feldblum's avatar
      Reimplement SignalSafeElfCache::Path · 8622363b
      Yedidya Feldblum authored
      Summary: [Folly] Reimplement `SignalSafeElfCache::Path` minimally so that it meets the expectations of `std::basic_string` as used by the rest of `SignalSafeElfCache`.
      
      Reviewed By: chadaustin, luciang
      
      Differential Revision: D23152224
      
      fbshipit-source-id: 48c7a7277d00a928d3de2937699ad112d6d560c2
      8622363b
    • Yedidya Feldblum's avatar
      Cut an extra rdtsc in DistributedMutex spin · bc6736ac
      Yedidya Feldblum authored
      Summary: [Folly] Cut an extra `rdtsc` in `DistributedMutex` spin.
      
      Reviewed By: aary
      
      Differential Revision: D21947987
      
      fbshipit-source-id: 8d6dca75f5290581a886385cefe994c19af839e1
      bc6736ac
  8. 13 Aug, 2020 2 commits
    • Mark Santaniello's avatar
      Introduce FallbackSysArenaAllocator · 8cde5e00
      Mark Santaniello authored
      Summary:
      It's difficult to use C++ allocators if they are not default-constructible.  The non-default-constructibility "infects" the container, and any class that holds the container (transitively).
      
      In D21967640 (https://github.com/facebook/folly/commit/f0471228b89be4a399afcf0e9692c84754d06875), I made `folly::SysArenaAllocator` default constructible, and adopted the behavior of merely throwing `std::bad_alloc` in the event that we didn't *actually* initialize it with a `folly::SysArena`.  In hindsight, it's not clear this was an improvement.  All it did was move a compile-time problem to run-time.
      
      What I do here is a bit better.  I enhance `CxxAllocatorAdaptor` such that it has two modes:
      - **Normal / classic mode:** non-default constructible.
        - Guaranteed at compile-time to have a non-null "inner allocator"
      - **`FallbackToStdAlloc` mode:** default-constructible.
        - Passes allocations through to `std::allocator` if no "inner allocator" provided
      
      Using this support, I introduce a new allocator, `folly::FallbackSysArenaAllocator`, which is similar to `SysArenaAllocator` *except* that it uses the fallback mode and is therefore default-constructible.
      
      This is useful in a large codebase where we want to use arena-allocation on a specific *instance* of a container type -- and not every single instance.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D22938039
      
      fbshipit-source-id: feaba12d76564a386a03e759eedf06a77bbc8942
      8cde5e00
    • Xavier Deguillard's avatar
      flush stdout before starting a command while interactive · 56693404
      Xavier Deguillard authored
      Summary:
      Now that the subprocess output is no longer piped, we can see a weird situation
      where the command being run is displayed after the compilation step:
        + cd /data/users/xavierd/scratch/dataZusersZxavierdZfbsource/fbcode_builder_getdeps/build/eden && \
        [1/13] rust_job_pool
            Finished release [optimized] target(s) in 0.75s
        [12/13] Install the project...
        -- Install configuration: "RelWithDebInfo"
        -- Installing: /data/users/xavierd/scratch/dataZusersZxavierdZfbsource/fbcode_builder_getdeps/installed/eden/bin/edenfs
        -- Set runtime path of "/data/users/xavierd/scratch/dataZusersZxavierdZfbsource/fbcode_builder_getdeps/installed/eden/bin/edenfs" to ""
        -- Up-to-date: /data/users/xavierd/scratch/dataZusersZxavierdZfbsource/fbcode_builder_getdeps/installed/eden/bin/edenfsctl
        -- Up-to-date: /data/users/xavierd/scratch/dataZusersZxavierdZfbsource/fbcode_builder_getdeps/installed/eden/lib/libbackingstore_rs.a
        -- Up-to-date: /data/users/xavierd/scratch/dataZusersZxavierdZfbsource/fbcode_builder_getdeps/installed/eden/lib/libbackingstore.a
        -- Up-to-date: /data/users/xavierd/scratch/dataZusersZxavierdZfbsource/fbcode_builder_getdeps/installed/eden/include/eden/scm/lib/backingstore/c_api/HgNativeBackingStore.h
        -- Up-to-date: /data/users/xavierd/scratch/dataZusersZxavierdZfbsource/fbcode_builder_getdeps/installed/eden/include/eden/scm/lib/backingstore/c_api/RustBackingStore.h
        + /data/users/xavierd/scratch/dataZusersZxavierdZfbsource/fbcode_builder_getdeps/installed/cmake-Ncng4tsJb6gdOu40ggy14-YtgNQD43 (https://github.com/facebook/folly/commit/f47621ec247c8009d8a8aae8823f0de7c27a70fe)k5ev0n-FXq99I/bin/cmake \
        +      --build \
        +      /data/users/xavierd/scratch/dataZusersZxavierdZfbsource/fbcode_builder_getdeps/build/eden \
        +      --target \
        +      install \
        +      --config \
        +      Release \
        +      -j \
        +      24
      
      This is a bit awkward. Flushing stdout's buffer allows for the ordering to be
      correct.
      
      Reviewed By: wez
      
      Differential Revision: D23079405
      
      fbshipit-source-id: e2bf25b098d6ab4a788a5ec07deb635a42cae18c
      56693404
  9. 12 Aug, 2020 7 commits
    • Chris Keeline's avatar
      Back out "Fix fiber backtraces in gdb" · 698754f3
      Chris Keeline authored
      Summary: Original commit changeset: 2d4ad67a4a01
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23064000
      
      fbshipit-source-id: 88d8d550772c2045f61d5a355cf33c9d8df7d046
      698754f3
    • Zach Zundel's avatar
      reclaimbale -> reclaimable · e9ae08b8
      Zach Zundel authored
      Summary: Found because I saw the error message
      
      Reviewed By: magedm
      
      Differential Revision: D23019298
      
      fbshipit-source-id: 6744e9e6d0c21cf76db756f68b3e948a044e6888
      e9ae08b8
    • Dan Melnic's avatar
      Fix TSAN-reported race in ShutdownSocketSet test · 621beb2e
      Dan Melnic authored
      Summary: [Folly] Fix TSAN-reported race in `ShutdownSocketSet` test where the shutdown does not wait for the server.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23057822
      
      fbshipit-source-id: 4b682e6e80cff503e85cb2b663f8399b69265a77
      621beb2e
    • Christopher Gist's avatar
      fix folly::fibers GDB extension for GCC 9 · 1aba9144
      Christopher Gist authored
      Summary:
      The folly::fibers GDB extension, specifically the `info fibers` command,
      depended on a specific format of the std::unique_ptr pretty printer
      output. This pretty printer format changed between GCC 7 and GCC 9, with
      the latter omitting the target address. However, the new pretty printer
      does expose an iterator for the child target address that we can use
      instead.
      
      Differential Revision: D23063364
      
      fbshipit-source-id: 6125edaba9abcfd0b7a9c0741a18854637c97804
      1aba9144
    • Mark Santaniello's avatar
      Eliminate lift_void_to_char · 09a33a57
      Mark Santaniello authored
      Summary:
      `std::allocator<void>::allocate` is not invocable as policy. Let folly allocators behave the same.
      
      Switch existing sites to parameterizing the allocators over `char` instead, since `std::allocator<char>::allocate` is invocable.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D22986960
      
      fbshipit-source-id: ca1ff3cb1785029b6b6f59ddc4046b1b105d8bd6
      09a33a57
    • Nathan Bronson's avatar
      fix forwarding for hinted insert_or_assign · efe2962d
      Nathan Bronson authored
      Summary:
      The hinted forms of insert_or_assign were forwarding with
      std::move rather than std::forward, which has the potential to elevate
      a non-const lvalue ref to an rvalue ref.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21475865
      
      fbshipit-source-id: e91e759762cf6f045c843cd7de1402953e6afb61
      efe2962d
    • Nathan Bronson's avatar
      Back out "suggest race condition to users that trip F14's internal checks" · cc16262f
      Nathan Bronson authored
      Summary: Original commit changeset: 8d5e96feea4d
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23046629
      
      fbshipit-source-id: e24c4a0ba5f40a584646a602f618e881dbf0f344
      cc16262f
  10. 11 Aug, 2020 2 commits
    • Robin Cheng's avatar
      Fix an issue in ElfCache that makes it async-signal-unsafe. · 8b650246
      Robin Cheng authored
      Summary:
      basic_fbstring unfortunately just ignores the allocator. Switching it to use std::basic_string.
      
      This is necessary because ElfCache must be async-signal-safe, but basic_fbstring ignores the allocator and always uses standard malloc/free, which are not safe async-signal-safe.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23035304
      
      fbshipit-source-id: 7b4e77a3764701366556a5fe5a352f952b052ed4
      8b650246
    • Robin Cheng's avatar
      Fix TSAN issues for //folly/io/async/test:async_test · 4506ae37
      Robin Cheng authored
      Summary:
      These are all test setup issues:
       - EventBase needs to be destructed before objects that callbacks may refer to.
       - A socket should not be operated on by a thread that is different from the event base it is associated with (in this case, the socket was being closed on the RSA computation thread).
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23043485
      
      fbshipit-source-id: 733868317aef09e32e79169aedb84a988de3bb41
      4506ae37