1. 21 Oct, 2020 5 commits
    • Davide Cavalca's avatar
      folly: always enable PIE in shared libs build · 3b1bdb98
      Davide Cavalca authored
      Summary:
      This reverts https://github.com/facebook/folly/pull/833 by adding back
      the unconditional setting of `POSITION_INDEPENDENT_CODE` when building shared
      libs. Without it, the build fails with a number of relocation errors. This was
      previously reported in https://github.com/facebook/folly/issues/983
      
      Differential Revision: D24449731
      
      fbshipit-source-id: 6f6cb71ef545d02998afb09909772b62657c1262
      3b1bdb98
    • Davide Cavalca's avatar
      folly: fix permissions on a couple of files · c20d1a93
      Davide Cavalca authored
      Summary: These do not need to be executable
      
      Differential Revision: D24449732
      
      fbshipit-source-id: 5f013c62dd6bf88fe4d50782a4c5bfcec6834aec
      c20d1a93
    • Michael Lee (Engineering)'s avatar
      `FOLLY_MAYBE_UNUSED` does not work on Windows · a55fdc39
      Michael Lee (Engineering) authored
      Summary:
      `frame` may be unused depending on whether it is compiled with or without asserts.
      
      `FOLLY_MAYBE_UNUSED` is supposed to take care of this, but it does not work on Windows and trips up the comiler:
      
      ```
      warning C4100: frame: unreferenced formal parameter
      ```
      
      Reviewed By: johnkearney, akrieger
      
      Differential Revision: D24451220
      
      fbshipit-source-id: 8225640a5e8fd0ceed4ffcc53cea7422a5581d6f
      a55fdc39
    • Yedidya Feldblum's avatar
      to_shared_ptr_aliasing · 9ffd6285
      Yedidya Feldblum authored
      Summary: [Folly] `to_shared_ptr_aliasing`, exposing the shared-ptr aliasing constructor as a free function deducing the types of its arguments.
      
      Reviewed By: Mizuchi
      
      Differential Revision: D24414504
      
      fbshipit-source-id: 290e822464860b824961986211375d87f942f483
      9ffd6285
    • Lewis Baker's avatar
      Update folly::fibers to preserve thread_local AsyncStackRoot · 039b4056
      Lewis Baker authored
      Summary:
      Updates the FiberManager to make sure that it saves/restores the current-thread's
      top-most active AsyncStackRoot when the coroutine is suspended/resumed.
      
      This is required for correctness to ensure async stack traces remain functional
      in the presence of fiber context-switches.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D21130668
      
      fbshipit-source-id: 4002bae0fc12a61c38836f9f099da4e6cf9183f4
      039b4056
  2. 20 Oct, 2020 2 commits
    • Alex Blanck's avatar
      Fix UndefinedBehaviorSanitizer error in `retryingPolicyCappedJitteredExponentialBackoff` · c663849f
      Alex Blanck authored
      Summary:
      While running some unit tests which happen to call into `folly::futures::retryingPolicyCappedJitteredExponentialBackoff`, I noticed that  `retryingJitteredExponentialBackoffDur` was triggering a "float-cast-overflow" error from UndefinedBehaviorSanitizer.
      
      It turns out that this only happened if `backoff_min` was 0 and there were at least 1025 retries. The large retry count caused the exponential term in the calculation to become `Infinity`. In floating point, Infinity multiplied by 0 was `NaN`, causing the sanitizer error.
      
      Although `backoff_min` should typically not be set to 0 because this effectively disables all backoff, I think there may be cases, such as unit tests, where setting `backoff_min` to 0 does make sense. This commit adds an additional check to handle this unusual case.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D24122470
      
      fbshipit-source-id: 48a8aede0d22e73cf001dab5eb184e841f3c23aa
      c663849f
    • Dan Melnic's avatar
      Remove FOLLY_HAVE_MSG_ERRQUEUE check · d1015a0b
      Dan Melnic authored
      Summary: Remove FOLLY_HAVE_MSG_ERRQUEUE check
      
      Reviewed By: yfeldblum
      
      Differential Revision: D24295244
      
      fbshipit-source-id: 24d4a69a013951b37fe7c93539b26eedf8113360
      d1015a0b
  3. 19 Oct, 2020 4 commits
    • Daniel Xu's avatar
      Use assert() instead of DCHECK · 81e350e1
      Daniel Xu authored
      Summary:
      We were seeing the following build failures on i386:
      ```
      In file included from folly/stats/detail/BufferedStat.h:151,
                       from folly/stats/QuantileEstimator.h:20,
                       from folly/stats/QuantileEstimator.cpp:17:
      folly/stats/detail/BufferedStat-inl.h: In member function 'void folly::detail::BufferedStat<DigestT, ClockT>::doUpdate(folly::detail::BufferedStat<DigestT, ClockT>::TimePoint, const std::unique_lock<folly::SharedMutexImpl<false> >&, folly::detail::BufferedStat<DigestT, ClockT>::UpdateMode)':
      folly/stats/detail/BufferedStat-inl.h:72:3: error: there are no arguments to 'DCHECK' that depend on a template parameter, so a declaration of 'DCHECK' must be available [-fpermissive]
         72 |   DCHECK(g.owns_lock());
            |   ^~~~~~
      ```
      
      My best guess is some kind of argument dependent lookup complication.
      
      This diff sidesteps the issue by using plain old `assert()` instead
      
      Reviewed By: yfeldblum
      
      Differential Revision: D24375147
      
      fbshipit-source-id: d702d883fcabc548e8f4969207e265abf21acf2b
      81e350e1
    • Dan Melnic's avatar
      AsyncUDPSocket: use actual controllen size instead of max · a07ea58a
      Dan Melnic authored
      Summary: AsyncUDPSocket: use actual controllen size instead of max
      
      Reviewed By: danobi
      
      Differential Revision: D24368739
      
      fbshipit-source-id: 0c1083a058d8fe0ddc212989a262f3eeebfa610c
      a07ea58a
    • Lukas Piatkowski's avatar
      rust/shed/hostname: rename hostname dependency to unbreak doctests (#15) · 1d8b0ebc
      Lukas Piatkowski authored
      Summary:
      Pull Request resolved: https://github.com/facebookexperimental/rust-shed/pull/15
      
      With the update from rustc 1.44 to 1.47 the doctests started to break when building a crate that depends on a different crate of the same name, see this: https://github.com/rust-lang/cargo/issues/6819
      
      This diff also removes the TravisCI build as it was broken and unused for some time.
      
      Reviewed By: krallin
      
      Differential Revision: D24390815
      
      fbshipit-source-id: fa9c78ef394640afbf8c419f8276bbf339960406
      1d8b0ebc
    • generatedunixname89002005325676's avatar
      Daily `arc lint --take CLANGFORMAT` · 6cc4b27d
      generatedunixname89002005325676 authored
      Reviewed By: zertosh
      
      Differential Revision: D24388883
      
      fbshipit-source-id: 6bba618c6a919cd3947d2a65954feff989bb80a2
      6cc4b27d
  4. 18 Oct, 2020 1 commit
    • Richard Barnes's avatar
      Add `midpoint()` calculation to folly · 430aa0d8
      Richard Barnes authored
      Summary:
      A number of libraries at Facebook include interval midpoint calculations; however, doing these in a mathematically precise way (without over/underflow) can be tricky. Doing them wrong can break binary searches over large datasets and give imprecise floating-point calculations.
      
      This function provides an early opportunity to fix binary searches and other calculations which can later be updated to `std::midpoint()` when C++20 becomes available.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23997097
      
      fbshipit-source-id: 373e0dc1d1ff071f697ee782be46fb0d49a2f8f7
      430aa0d8
  5. 17 Oct, 2020 1 commit
    • Xavier Deguillard's avatar
      logging: fix prefix stripping on Windows · 9db54edd
      Xavier Deguillard authored
      Summary:
      Windows paths can both use forward slashes as well as backslashes, and also
      contain colons that folly uses to separate prefixes to strip.
      
      The xlogStripFilename unfortunately didn't handle both of these cases leading
      to log categories to always contain the full path instead of a suffix path.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D24353208
      
      fbshipit-source-id: ff17afe4b46f36d46bf468a5e3cf9ba9ba8412b8
      9db54edd
  6. 16 Oct, 2020 6 commits
    • Robin Cheng's avatar
      Relax the stack trace limit for opt mode too. · 308bab0e
      Robin Cheng authored
      Summary:
      Similar to D24179337 (https://github.com/facebook/folly/commit/7cc28784d1749283b7eb78399a0f0a77594dbc14).
      
      Though I'm not actually sure what's causing the increase... maybe the right thing to do is the debug the underlying cause, but I'm also not sure how to debug this exactly.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D24353676
      
      fbshipit-source-id: 12bc5eae939f95d8d091280dc5b5af638f0152a0
      308bab0e
    • Xavier Deguillard's avatar
      HazptrDomain: fix MSVC truncation warning · 2b5dedea
      Xavier Deguillard authored
      Summary:
      The MSVC compiler complains about truncation of size_t to int:
      
        Z:\installed\folly\include\folly/synchronization/HazptrDomain.h(210): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
      
      MSVC being very verbose, this is followed by 25 lines of template expansion.
      
      Since `shard` is a size_t due to `calc_shard` returning that type, let's simply
      make the shard argument of hazptr_warning_list_too_large a size_t too to
      silence the warning.
      
      Reviewed By: magedm
      
      Differential Revision: D24365556
      
      fbshipit-source-id: b426cee7caaf593eb112691bc45b83e564342b0e
      2b5dedea
    • Lukas Piatkowski's avatar
      mononoke/integration: create a Makefile to run tests as part of getdeps.py build (#67) · 3f6324de
      Lukas Piatkowski authored
      Summary:
      Pull Request resolved: https://github.com/facebookexperimental/eden/pull/67
      
      With this change it will be possible to build dependencies of and run integration tests using getdeps.py.
      
      This is the first goal of Q4 as per https://fb.quip.com/v8YzAYNSYgot: "Get Open Source version of integration tests running on Legocastle".
      
      Before this diff:
      The OSS integration tests run now on GitHub by:
      - Building some test dependencies with getdeps.py
      - Building some test dependencies with homebrew/apt-get
      - Running tests via python script
      
      The OSS integration tests were not running on Sandcastle.
      
      After this diff:
      The OSS integration tests run on Github by:
      - Building and executing tests via getdeps.py (execution of tests happens by getdeps.py calling Make calling python script)
      
      The OSS integration tests run on Sandcastle using the same getdeps.py setup as Github.
      
      Reviewed By: krallin
      
      Differential Revision: D24253268
      
      fbshipit-source-id: cae249b72d076222673b8bbe4ec21866dcdbb253
      3f6324de
    • Christopher Kuklewicz's avatar
      Improve documentation comments on EventBaseManager · b26907ea
      Christopher Kuklewicz authored
      Summary:
      # What is the goal?
      
      Address the problem in the post at https://fb.workplace.com/groups/code.indexing/permalink/1929080303917865/ with the comment(s) in Codex for EventBaseManager.
      
      # What was not the way?
      
      Jie Jua noticed that the current comment on "EventBaseManager() {}" in Codex was
      
      ```
      encouraged. You should instead use the global singleton if possible.
      ```
      
      # What is the new way?
      
      Use documentation comments (doxygen) style `/** double starts */` instead of `//` ordinary comments. This should show the full comment which is:
      
      ```
      XXX Constructing a EventBaseManager directly is DEPRECATED and not
      encouraged. You should instead use the global singleton if possible.
      ```
      
      Which really needs that first line.
      
      Differential Revision: D24333522
      
      fbshipit-source-id: 8e84e0a49426844d5a6f6438b0d76fb9886742fe
      b26907ea
    • Orvid King's avatar
      Use the new name for await in the fibers test · 53947e04
      Orvid King authored
      Summary: The bare name isn't defined on windows at all, so we have to use the new internal name instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D24044971
      
      fbshipit-source-id: 24b37903ed0f309910d9f5141240b951bf5fba15
      53947e04
    • Alfred Fuller's avatar
      Move clang-format-next changes into clang-format-canary · 0deef031
      Alfred Fuller authored
      Reviewed By: yfeldblum
      
      Differential Revision: D23545773
      
      fbshipit-source-id: e93f84d0658166e875710a4c0fb5dc165a8628d8
      0deef031
  7. 15 Oct, 2020 9 commits
    • Andrew Huang's avatar
      Migrate AsyncSSLSocketTest to V2 Session API · 3fa19ab2
      Andrew Huang authored
      Summary: Migrate AsyncSSLSocketTest to new AsyncSSLSocket session API
      
      Reviewed By: mingtaoy
      
      Differential Revision: D24240249
      
      fbshipit-source-id: ea9bd7669f377c738e44d3348400a2cfbd3c2580
      3fa19ab2
    • Robin Cheng's avatar
      Fix livelock in AtForkTest when running under TSAN. · 08ee18c5
      Robin Cheng authored
      Summary: Use the forkInstrumented call when running under TSAN.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23787959
      
      fbshipit-source-id: 159f8354ef9746b8374d6da12b22e389c2bc71f4
      08ee18c5
    • Yedidya Feldblum's avatar
      Fix is_constexpr_default_constructible under clang-10 · 068d3f6e
      Yedidya Feldblum authored
      Summary: [Folly] Fix `is_constexpr_default_constructible` under clang-10, which suffers a crash (https://bugs.llvm.org/show_bug.cgi?id=47620) and divergent behavior in certain constexpr evaluations.
      
      Reviewed By: mpark, Mizuchi
      
      Differential Revision: D24302661
      
      fbshipit-source-id: b6a58b5b675f367bf2dc1d810edb9926cfb87a2e
      068d3f6e
    • Dan Melnic's avatar
      TSAN fix for folly/io/test:shutdown_socket_set_test · 7c4ac999
      Dan Melnic authored
      Summary: TSAN fix for folly/io/test:shutdown_socket_set_test
      
      Differential Revision: D24321155
      
      fbshipit-source-id: 753a808c868da4c608c3ee95d16a3673d6f700b0
      7c4ac999
    • Dan Melnic's avatar
      Reduce io_uring test mem requirements · af60f10a
      Dan Melnic authored
      Summary: Reduce io_uring test mem requirements
      
      Reviewed By: xiaofeidu008, danobi
      
      Differential Revision: D24314788
      
      fbshipit-source-id: 35ec01475fbc1cf851a81e33cf8c7fec8dd88ddb
      af60f10a
    • Andrii Grynenko's avatar
      Unwrap Observer in SimpleObservable cache · fbfab7ff
      Andrii Grynenko authored
      Summary: Cache unwrapped observer instead of unwrapping it on every getObserver call.
      
      Reviewed By: jmswen
      
      Differential Revision: D24325934
      
      fbshipit-source-id: d8a023e59c933222a5f43aaacbd9c955236739b3
      fbfab7ff
    • Maged Michael's avatar
      ConcurrentHashMap: Remove comment about potential bottleneck under heavy removal · 2bf4a236
      Maged Michael authored
      Summary:
      Remove comment about potential high contention under sustained frequent removal from CHM-s.
      
      Recent changes to the hazard pointer library eliminated this problem:
      - Asynchronous reclamation of tagged objects (including CHM objects) no longer needs to be done while holding the lock on the list of tagged objects.
      - The list of tagged objects is now sharded and sharding can be easily increased if needed.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D24318407
      
      fbshipit-source-id: 3124e8d5651848a16084899a6f31d69cc235c702
      2bf4a236
    • John Reese's avatar
      apply black 20.8b1 formatting update · 68c04406
      John Reese authored
      Summary:
      allow-large-files
      
      black_any_style
      
      Reviewed By: zertosh
      
      Differential Revision: D24325133
      
      fbshipit-source-id: b4afe80d1e8b2bc993f4b8e3822c02964df47462
      68c04406
    • Robin Cheng's avatar
      Relax the limits for StackTraceSizeLimitTest. · 7cc28784
      Robin Cheng authored
      Summary: Apparently it's flaky...
      
      Differential Revision: D24179337
      
      fbshipit-source-id: 75416adaf8dbd37fc9ddeaa0500ddfaeb80cffa9
      7cc28784
  8. 14 Oct, 2020 4 commits
    • Yedidya Feldblum's avatar
      Cut linter suppression in TryTest.cpp · 98014f8b
      Yedidya Feldblum authored
      Summary: [Folly] Cut linter suppression in `TryTest.cpp`.
      
      Reviewed By: zertosh
      
      Differential Revision: D24294536
      
      fbshipit-source-id: 64b26ec4632ffdae8e246aa27a6c58c579e2db10
      98014f8b
    • Dan Melnic's avatar
      Move folly binary · 3f1e1ee8
      Dan Melnic authored
      Summary: Move folly binary
      
      Reviewed By: yfeldblum
      
      Differential Revision: D24294709
      
      fbshipit-source-id: e7cf0be6e45d3a132fc81143103f3b5cdedbb76f
      3f1e1ee8
    • Xiaofei Du's avatar
      Conserve resource for IoUringBackendTest to avoid rlimit issue · ef6f7573
      Xiaofei Du authored
      Summary:
      This is best effort. We cannot control how many tests are running
      at the same time. And if the user is running other tests that consumes resource
      
      Differential Revision: D24289056
      
      fbshipit-source-id: 0810ba0989e84a5bce6d695dd6df0dfe2618fbf7
      ef6f7573
    • Francesco Zoffoli's avatar
      CoReturn can return implicitly convertible values · bf475c74
      Francesco Zoffoli authored
      Summary:
      Gmock's `Return(x)` is a valid action as long as `x` is implicitly convertible to the return type of the function.
      
      The current implementation of `CoReturn(x)` does not support that, since `Task<T>` is not convertible to `Task<Q>` even if `Q` is convertible to `T`.
      
      This diff changes the `CoReturn` implementatio to match the way Gmock does, allowing for the implicit conversion.
      
      This is extremely valuable when using `Task<Expected<...>>`, as it allows to write `CoReturn(makeUnexpected(...))` instead of `CoReturn(Expected<...>(unexpected, ...))`.
      
      It also make the translation from a mock being sync to async more straightforward: add `Task` in the mock return type and replace `Return` with `CoReturn`.
      
      Reviewed By: lewissbaker
      
      Differential Revision: D24046013
      
      fbshipit-source-id: 9f166237a624600be51c00616f145ae4e1a45443
      bf475c74
  9. 13 Oct, 2020 2 commits
    • Lukas Piatkowski's avatar
      mononoke/integration tests: prepare dependencies for running tests by getdeps · 22ed347d
      Lukas Piatkowski authored
      Summary:
      This diff adds all third party dependencies that are required by getdeps to be able to build and runn Mononoke's integration tests.
      
      Also add a stub Makefile with no-op steps that will be filled in next diff.
      
      Reviewed By: ahornby
      
      Differential Revision: D24251894
      
      fbshipit-source-id: 67384ecfd0ced6762dddc3c6e61feb1240b1162d
      22ed347d
    • Andrii Grynenko's avatar
      Fix Core::hasCallback to return true for State::Empty · 8eba7be7
      Andrii Grynenko authored
      Summary:
      This specifically fixes a TSAN detected race where SemiFuture destructor was checking Core state to see if deferred executor has to be detached, while that state could become Empty if the callback is being proxied and both threads code be racing while accessing the executor.
      hasCallback() checks if the callback was ever set (not if the callback is stil alive) and it's true for State::Empty (similar to State::Done).
      
      Differential Revision: D24271346
      
      fbshipit-source-id: 5f52f20783d36745d1200497e0300bc086b65213
      8eba7be7
  10. 10 Oct, 2020 1 commit
    • Dan Melnic's avatar
      Add support for UDP RX timestamps · 1902d0ff
      Dan Melnic authored
      Summary: Add support for UDP RX timestamps
      
      Reviewed By: mjoras
      
      Differential Revision: D24146914
      
      fbshipit-source-id: 381839fc5402f13e428364c47c5752473acda6af
      1902d0ff
  11. 09 Oct, 2020 3 commits
    • Ivan Murashko's avatar
      `lint-ignore` processing for `clang-tidy` (xplat) · 343a70ae
      Ivan Murashko authored
      Summary: Disable CLANGTIDY checks for several places at the code where HOWTOEVEN checks are disabled.
      
      Reviewed By: suo
      
      Differential Revision: D24198276
      
      fbshipit-source-id: c52cd10941252fcacfea30589660c57eb7099011
      343a70ae
    • Ivan Murashko's avatar
      `lint-ignore` processing for `clang-tidy` (fbcode addons) (#1472) · 4f9a125a
      Ivan Murashko authored
      Summary:
      Pull Request resolved: https://github.com/facebook/folly/pull/1472
      
      Disable CLANGTIDY checks for several places at the code where HOWTOEVEN checks are disabled.
      
      Reviewed By: suo
      
      Differential Revision: D24197524
      
      fbshipit-source-id: e99cfe1a7440a275edd63643ad819ca9e2a07788
      4f9a125a
    • John Kearney's avatar
      Allow folly fibers to compile with windows asan · d15d9f55
      John Kearney authored
      Summary:
      - Folly FiberManager makes the assumption that asan always has dlfcn.h
         available.
         - This assumption is not true on windows.
       - This diff would mean that windows asan would not use:
         - `__sanitizer_start_switch_fiber`
         - `__sanitizer_finish_switch_fiber`
         - `__asan_unpoison_memory_region`
       - The behavior of `GetProcAddress` on windows is sufficiently different to `dlsym` to make switching to it without significant testing unappealing.
      
      (Note: this ignores all push blocking failures!)
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D24167183
      
      fbshipit-source-id: 2587a4000901b5e3a8857e9aa5816270d2be34dc
      d15d9f55
  12. 08 Oct, 2020 2 commits
    • Robin Cheng's avatar
      Make ThreadCachedInts TSAN-friendly. · b984cc9d
      Robin Cheng authored
      Summary:
      ThreadCachedInts uses asymmetric barriers to heavily optimize the reader side. TSAN does not support (symmetric or asymmetric) barriers. In this particular case, this diff replaces the memory order for accessing increments and decrements with memory_order_seq_cst only when running under TSAN, and that, I think, is a valid alternative to the barriers because it ensures a total order between all atomic accesses to increments and decrements (so that, when we read all decrements before all increments, we make sure that any writes to increments are read as long as decrements are read, which seems to be the purpose of the barriers).
      
      Introduced additional tests to RcuTest and to AtomicReadMostlyMainPtrTest. The problem with existing tests is that this only triggers TSAN when the counter was already 0 when calling synchronize(), not when synchronize() had to invoke futexWait, because futexWait is itself a synchronization point.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D24029131
      
      fbshipit-source-id: 57c7bf32061868ccd5a4e20154c8c7db6e4eeef5
      b984cc9d
    • Lee Howes's avatar
      Add weakDetachOnGlobalCPUExecutorAfter · bb70495b
      Lee Howes authored
      Summary: Adds a form of detach that is safe to use in recursive code. Detaches a task after a delay, and checks for availability of the global executor at that point to decouple shutdown from the delayed detach.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D24174495
      
      fbshipit-source-id: e6b22485a817c18319c897fd51c3f8ba81d13041
      bb70495b