1. 11 Sep, 2020 2 commits
    • Ivan Egorov's avatar
      Allow symbolizer to fall back to getStackTraceSafe · 61a00871
      Ivan Egorov authored
      Summary: This makes sense on systems without `backtrace` and with LLVM libunwind implementations.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23625739
      
      fbshipit-source-id: 6ec50c94c73bda227118ffc36d6856bcd8dd0d8b
      61a00871
    • Nathan Bronson's avatar
      optimized helper for constructing aliasing std::weak_ptr · 90607a25
      Nathan Bronson authored
      Summary:
      `std::shared_ptr` has an aliasing constructor, but `std::weak_ptr`
      has none.  This diff implements a helper function that implements the
      functionality.  For libstdc++ it uses ABI-specific hacks to avoid the
      need to construct a temporary `std::shared_ptr`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23580416
      
      fbshipit-source-id: 71712270519b0e7522d8019a5c356679c7dc5397
      90607a25
  2. 10 Sep, 2020 8 commits
    • Yedidya Feldblum's avatar
      Decay char-array and trivial args to throw_exception · 704c7ec4
      Yedidya Feldblum authored
      Summary:
      [Folly] Decay char-array and trivial args to `throw_exception` and `terminate_with`.
      
      The motivation is to ensure smaller call-site code size in the common cases, where the solitary argument is a string literal. Extend to cases where arguments are numbers and the like as well, since that is simple enough and is something that `Function` already does.
      
      Reviewed By: aary
      
      Differential Revision: D23550096
      
      fbshipit-source-id: d3a2066dc28dc4cfac6b65e2b8972613ce55d06c
      704c7ec4
    • Yedidya Feldblum's avatar
      byte · ad37aadb
      Yedidya Feldblum authored
      Summary: [Folly] `byte`, backported from `std::byte` in C++17.
      
      Reviewed By: Alfus, vitaut
      
      Differential Revision: D23535105
      
      fbshipit-source-id: 056c634362b2ca226306a97ae9994a4631d07ee5
      ad37aadb
    • Orvid King's avatar
      Include process.h in portability/Unistd.h · 10ee4469
      Orvid King authored
      Summary: In newer versions of the windows STL, this gets included in <thread>, so explicitly include it in Unistd.h and remove the definition of getpid.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23498073
      
      fbshipit-source-id: 5fe07dbbaa9fb1bf5c904286bd15beccbf1d1615
      10ee4469
    • Yedidya Feldblum's avatar
      Revise invoke and invocability traits · 4bf029a2
      Yedidya Feldblum authored
      Summary:
      [Folly] Revise invoke to be an invoker rather than a function, and therefore insusceptible to ADL, and revise invocability traits for compile-time perf.
      
      Do the same for apply and applicability traits.
      
      Reviewed By: Mizuchi
      
      Differential Revision: D23334895
      
      fbshipit-source-id: 4d3241a3f34a7bede44f8ab54a30a3074d9fd3ed
      4bf029a2
    • Yedidya Feldblum's avatar
      Tweaks to hash primitives · 533d54f5
      Yedidya Feldblum authored
      Summary: [Folly] Tweaks to hash primitives: twang, jenkins_rev, fnv
      
      Reviewed By: ot, luciang
      
      Differential Revision: D23290185
      
      fbshipit-source-id: 080dfa8a5f357065473f3973654c91d01c683c3c
      533d54f5
    • Robin Cheng's avatar
      Fix an unnecessary racy access in SingleWriterFixedHashMap on empty iterator · bfde457b
      Robin Cheng authored
      Summary:
      When grabbing an iterator when the map is empty, size is zero but we
      still create a copy of the elem_ pointer which is invalid to do when the size
      is zero (since the writer could overwrite the pointer upon first insertion).
      This diff checks whether the iterator would be empty and if so avoid grabbing
      that pointer.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23520616
      
      fbshipit-source-id: 5b3f2bc3a9b935920e7fd616e64fadafd7775a75
      bfde457b
    • Robin Cheng's avatar
      Fix an atomic memory ordering in DefaultKeepAliveExecutor. · b172ccdf
      Robin Cheng authored
      Summary: Honestly I haven't spent time to understand why this order needs to be acq_rel, but (1) it's the same as the one used in the other keepAliveRelease in this file (2) this ordering is free for read-modify-write operations (3) TSAN said this works :)
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23495784
      
      fbshipit-source-id: 8bdcafb14b27e6c0f8838ed478364821cd39f9a9
      b172ccdf
    • Yedidya Feldblum's avatar
      Fix the reentrant_allocator loop · c26af9db
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix the `reentrant_allocator` internal loop, which when finding a new head node would incorrectly preserve the free `offset` corresponding to the previous head.
      
      Hat tip to hpmv for the report.
      
      Differential Revision: D23593517
      
      fbshipit-source-id: b4fc701f08056184225e7feac32d60aabf7ea6cc
      c26af9db
  3. 09 Sep, 2020 10 commits
    • Adam Simpkins's avatar
      remove older fbcode_builder_config.py file · d5d33bcf
      Adam Simpkins authored
      Summary:
      Remove the old `fbcode_builder_config.py` file used by the previous
      incarnation of fbcode_builder.  This file hasn't been used in a while now.
      Folly instead builds with `build/fbcode_builder/getdeps.py`, which uses the
      configuration file at `build/fbcode_builder/manifests/folly`
      
      Reviewed By: wez
      
      Differential Revision: D23591355
      
      fbshipit-source-id: b2e193c7dc54dcf481557984b5833fa92ff4049c
      d5d33bcf
    • Adam Simpkins's avatar
      add a top-level build.sh to build folly via getdeps.py · 0fa80a4d
      Adam Simpkins authored
      Summary:
      Add a small top-level build.sh script that invokes
      build/fbcode_builder/getdeps.py to perform the build.  This primarily helps
      make the getdeps build process more discoverable to users.
      
      Also document this script in README.md
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23484822
      
      fbshipit-source-id: 6013ace6d80d7d3d80aa87d4c6269ac106814cf0
      0fa80a4d
    • Adam Simpkins's avatar
      update fbcode_builder README to document getdeps.py · b3521215
      Adam Simpkins authored
      Summary:
      Update the `README.md` file in the fbcode_builder subdirectory to document the
      current getdeps.py build system rather than the older fbcode_builder scripts
      that required each project to keep their own python-based build files in their
      project directory.
      
      Reviewed By: chadaustin, wez
      
      Differential Revision: D23591356
      
      fbshipit-source-id: 75a099a10793e68a2b59696682010c4dff47ec69
      b3521215
    • Sim Sun's avatar
      Revert D23489967: Modify Future::getTryVia to be r-value qualified and destructive · c9993790
      Sim Sun authored
      Differential Revision:
      D23489967 (https://github.com/facebook/folly/commit/65bb1505d3f64d9248bc1f7a04abc212db518676)
      
      Original commit changeset: db11c9c5946e
      
      fbshipit-source-id: 4970fc7de479a51d4acf91b2871ff0c15712130e
      c9993790
    • Adam Simpkins's avatar
      fix FindDoubleConversion.cmake to work properly · 7187a3af
      Adam Simpkins authored
      Summary:
      The code in `FindDoubleConversion.cmake` called
      `FIND_PACKAGE_HANDLE_STANDARD_ARGS()` with the wrong arguments.  The first
      argument must match the package name: since this file is called
      `FindDoubleConversion` the first argument must be `DoubleConversion`.
      
      Previously this code was passing in `DOUBLE_CONVERSION`, causing it to set
      `DOUBLE_CONVERSION_FOUND` instead of `DoubleConversion_FOUND`.  Since this
      module did not set `DoubleConversion_FOUND` the `find_package()` call assumed
      it always succeeded, even when the double-conversion library was not found.
      
      Also remove the extra status message.  `FIND_PACKAGE_HANDLE_STANDARD_ARGS()`
      already prints out a status message as long as `find_package()` was called
      without the `QUIET` argument.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23588980
      
      fbshipit-source-id: 8c088930b1b01c027403c3e425f1924f6149f72a
      7187a3af
    • Adam Simpkins's avatar
      update FindGflags.cmake to work on CentOS 8.x (#1409) · 41b44bcf
      Adam Simpkins authored
      Summary:
      Update FindGflags.cmake to work on recent CentOS and RedHat distributions.
      
      On these distributions the CMake package configuration installed by the
      gflags-devel RPM is slightly broken, and sets `gflags_INCLUDE_DIR` to a
      directory that does not exist.  This happens because `/lib64` is symlinked to
      `/usr/lib64`, and CMake ends up searching `/lib64` before `/usr/lib64` by
      default when searching for packages.  Therefore it finds `gflags-config.cmake`
      via the `/lib64` symlink.  However, `gflags-config.cmake` computes the include
      directory relative to where its config file was found, and this relative path
      computation only works when using the actual `/usr/lib64` path where it was
      installed.  When found via `/lib64` it returns a bogus `//include` path that
      does not exist.
      
      This updates `FindGflags.cmake` to verify if the `gflags_INCLUDE_DIR` path
      actually exists, and set it to a sane location instead.
      
      This also updates the code to use the `gflags-shared` target that is exported
      by the default gflags package configuration if it was only built as a shared
      library.
      
      Pull Request resolved: https://github.com/facebook/folly/pull/1409
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23588288
      
      fbshipit-source-id: b68a717953ae0521f568d7bcfd05ca33cd6dc578
      41b44bcf
    • Chad Austin's avatar
      use FOLLY_HAVE_BACKTRACE to guard execinfo.h and usage of backtrace(3) · 2a41679b
      Chad Austin authored
      Summary:
      FOLLY_USE_SYMBOLIZER is a poor guard for the existence of execinfo.h
      and backtrace(3), which is widely available on unix platforms, but not
      available on Android NDK. Instead, introduce FOLLY_HAVE_BACKTRACE and
      have CMake detect its availability.
      
      Reviewed By: yfeldblum, luciang
      
      Differential Revision: D23361495
      
      fbshipit-source-id: 4409363f3eaa754977a93e1f006c5911d8e32020
      2a41679b
    • Chad Austin's avatar
      fix macOS build · 6e269d82
      Chad Austin authored
      Summary: Darwin libc doesn't implement quick_exit, so use std::_Exit instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23592838
      
      fbshipit-source-id: bda318216239965e14b4c97ca184a2303353ed73
      6e269d82
    • Lee Howes's avatar
      Modify Future::getTryVia to be r-value qualified and destructive · 65bb1505
      Lee Howes authored
      Summary: For consistency with get() make getTryVia r-value qualified and move the result out. This has the benefit of removing surprise copies in code that already operated on a temporary future but ended up with an l-value reference to copy from as a result of this operation.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23489967
      
      fbshipit-source-id: db11c9c5946edd402103b3aa4140c0a1db5aae5e
      65bb1505
    • Raul Tambre's avatar
      CMake: Fix version comparison for target argument (#1439) · fdc44f51
      Raul Tambre authored
      Summary:
      VERSION_GREATER 3.18 also matches 3.18.2, which is wrong as the target argument was only added in 3.19.
      After noticing that folly requires an ancient CMake version I converted over from VERSION_GREATER_EQUAL and introduced the comparison error.
      
      Issue reported [here](https://github.com/facebook/folly/pull/1433#discussion_r484278801).
      
      Pull Request resolved: https://github.com/facebook/folly/pull/1439
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23564812
      
      Pulled By: Orvid
      
      fbshipit-source-id: 19881876147ec73ad70610cf97c408740f998340
      fdc44f51
  4. 08 Sep, 2020 7 commits
    • Matt Ma's avatar
      Use compilation unit as base address when no base address exists for range. · 046adb70
      Matt Ma authored
      Summary:
      From Dwarf4 standard
      
      http://dwarfstd.org/doc/DWARF4.pdf#page=53
      
      ```name=2.17.3 Non-Contiguous Address Ranges
      The applicable base address of a range list entry is determined by the closest preceding base
      address selection entry (see below) in the same range list. If there is no such selection entry, then
      the applicable base address defaults to the base address of the compilation unit (see Section
      3.1.1).
      
      In the case of a compilation unit where all of the machine code is contained in a single
      contiguous section, no base address selection entry is needed.
      ```
      
      http://dwarfstd.org/doc/DWARF4.pdf#page=58
      
      ```name=3.1.1 Normal and Partial Compilation Unit Entries
      Compilation unit entries may have the following attributes:
      
      1. Either a DW_AT_low_pc and DW_AT_high_pc pair of attributes or a DW_AT_ranges
      attribute whose values encode the contiguous or non-contiguous address ranges, respectively,
      of the machine instructions generated for the compilation unit (see Section 2.17).
      A DW_AT_low_pc attribute may also be specified in combination with DW_AT_ranges to
      specify the default base address for use in location lists (see Section 2.6.2) and range lists
      (see Section 2.17.3).
      ```
      
      http://dwarfstd.org/doc/DWARF4.pdf#page=61
      
      ```name=3.1.1 Normal and Partial Compilation Unit Entries
      The base address of a compilation unit is defined as the value of the DW_AT_low_pc attribute,
      if present; otherwise, it is undefined. If the base address is undefined, then any DWARF entry or
      structure defined in terms of the base address of that compilation unit is not valid.
      ```
      
      http://dwarfstd.org/doc/DWARF4.pdf#page=52
      ```name=2.17 Code Addresses and Ranges  - 2.17.1 Single Address
      When there is a single address associated with an entity, such as a label or alternate entry point
      of a subprogram, the entry has a DW_AT_low_pc attribute whose value is the relocated address
      for the entity.
      
      While the DW_AT_entry_pc attribute might also seem appropriate for this purpose, historically
      the DW_AT_low_pc attribute was used before the DW_AT_entry_pc was introduced (in DWARF
      Version 3). There is insufficient reason to change this.
      ```
      
      Reviewed By: luciang
      
      Differential Revision: D23422082
      
      fbshipit-source-id: 4de79fa81e6c323095bb7c79faf87369998138c6
      046adb70
    • Giuseppe Ottaviano's avatar
      Use AccessSpreader::cachedCurrent() in CoreCachedSharedPtr · dcbe5421
      Giuseppe Ottaviano authored
      Summary: Avoid an expensive `__vdso_getcpu` on every `get()`.
      
      Reviewed By: terrelln
      
      Differential Revision: D23469601
      
      fbshipit-source-id: 6c7e62a136b7cd80baab6dcfb10cba13a2e472c0
      dcbe5421
    • Maged Michael's avatar
      Add folly::get_cached_pid() · 04513e57
      Maged Michael authored
      Summary:
      The function folly::get_cached_pid() saves and reuses the result of calling getpid().
      At fork, the value is updated for the child process.
      
      It is thread-safe. The first call is async-signal-unsafe but subsequent calls are async-signal-safe.
      
      Reviewed By: yfeldblum, davidtgoldblatt
      
      Differential Revision: D23433702
      
      fbshipit-source-id: a026300206c1726fc1c2c6a588828f2e6559c4e2
      04513e57
    • Lee Howes's avatar
      Add getTry back into folly::Future, with blocking behaviour consistent with... · 93b940f7
      Lee Howes authored
      Add getTry back into folly::Future, with blocking behaviour consistent with get() and with SemiFuture::getTry().
      
      Summary:
      Formerly Future::getTry was non-blocking, and exhibited confusing behaviour of throwing on timeouts, but returning a try containing exceptions related to the workload of the future. This was inconsistent with Future::get, and thus surprising.
      
      An earlier change safely removed this broken version of the operation. Here we add it back in with consistent behaviour.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23477042
      
      fbshipit-source-id: afda6b37c86531dab43ac31ec6d605cc6c5d670c
      93b940f7
    • Yedidya Feldblum's avatar
      A few nits for constexpr_strlen, constexpr_strcmp · faaf3a5d
      Yedidya Feldblum authored
      Summary: [Folly] A few nits for `constexpr_strlen`, `constexpr_strcmp`.
      
      Reviewed By: ericniebler
      
      Differential Revision: D23547224
      
      fbshipit-source-id: f232861f5cc4dbd5eb77c4bbe3b9766fd233e9f5
      faaf3a5d
    • Robin Cheng's avatar
      Fix a simple race condition FutureDAGTest. · d6931011
      Robin Cheng authored
      Summary:
      In the "Complex" test we can have nodes running at the same time. So
      appending to the same vector concurrency isn't safe. Protecting that with a
      mutex.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23545746
      
      fbshipit-source-id: b6f6e8b7204cf63c7e8fbbd8fc5134cb66c8180a
      d6931011
    • Ivan Egorov's avatar
      Avoid VLA in DWARF symbolizer · 3427f219
      Ivan Egorov authored
      Summary: Variable length arrays are an extension to C++ standard that is not universally supported. Use a fixed size array instead.
      
      Differential Revision: D23563131
      
      fbshipit-source-id: 743e65838e83286ea28d8de10cd9d4416e6e4e91
      3427f219
  5. 07 Sep, 2020 1 commit
  6. 06 Sep, 2020 2 commits
    • Ivan Egorov's avatar
      Add a note into constexpr_strcmp · 18fd6fc8
      Ivan Egorov authored
      Summary: This explains why the commonly used `int(*s1 - *s2)` was changed to a slightly less obvious alternative.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23537394
      
      fbshipit-source-id: 152554bc9864cdf25c569216d21b0c04bea67e9d
      18fd6fc8
    • Orvid King's avatar
      Include ostream in SymbolizedFrame · 809c5665
      Orvid King authored
      Summary: This is used so needs to be included. MSVC 2019's STL exposes this.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23497796
      
      fbshipit-source-id: 612e0fb91c5d5637c25d062a4b3afc0c67344012
      809c5665
  7. 05 Sep, 2020 1 commit
    • Yedidya Feldblum's avatar
      Fix StaticSingletonManager::create_<true> · 2a6bb416
      Yedidya Feldblum authored
      Summary: [Folly] Fix `StaticSingletonManager::create_<true>` which is missing the `noexcept` specification.
      
      Reviewed By: Mizuchi, xavierd
      
      Differential Revision: D23552042
      
      fbshipit-source-id: 629ad215602125a3e6322b36948df78c62fbef15
      2a6bb416
  8. 04 Sep, 2020 8 commits
    • Yedidya Feldblum's avatar
      Limit StaticSingletonManager check functions · fef268ac
      Yedidya Feldblum authored
      Summary: [Folly] Limit `StaticSingletonManager` check functions to `StaticSingletonManager` calls.
      
      Reviewed By: Alfus
      
      Differential Revision: D23544598
      
      fbshipit-source-id: 081d324064025d5fc86bb20b9b685c2591f01642
      fef268ac
    • Yedidya Feldblum's avatar
      Let noexcept StaticSingletonManager::create be outline · 25878e4b
      Yedidya Feldblum authored
      Summary: [Folly] Let `noexcept` member function template `StaticSingletonManager::create` be outline to avoid pathological inline path behavior.
      
      Reviewed By: iahs
      
      Differential Revision: D23522488
      
      fbshipit-source-id: 5ec9ed271b814f4496812e226e0f0929f65565a2
      25878e4b
    • Yedidya Feldblum's avatar
      Add missing < 0 tests for constexpr_strcmp · 1c185362
      Yedidya Feldblum authored
      Summary: [Folly] Add missing `< 0` tests for `constexpr_strcmp` to verify that the implementation is symmetric.
      
      Reviewed By: Mizuchi
      
      Differential Revision: D23482134
      
      fbshipit-source-id: d3cb1fe8ce4690a34a12620eb57e7a8ff57ad8a1
      1c185362
    • Yedidya Feldblum's avatar
      Make is_same failures easier to diagnose in constexpr_strlen tests · eaca25f6
      Yedidya Feldblum authored
      Summary: [Folly] Make `is_same` failures easier to diagnose in `constexpr_strlen` tests.
      
      Reviewed By: Mizuchi
      
      Differential Revision: D23481769
      
      fbshipit-source-id: a990e1b96381f976feb7b4d3efda860f38fb6fe3
      eaca25f6
    • Andrew Huang's avatar
      Fix SSLSessionTest for TravisCI (Ubuntu) · 7d52648f
      Andrew Huang authored
      Summary:
      These tests pass in our build system, and fail on other platforms (Ubuntu, Darwin). Specifically, they cause our folly's CI to fail, since it's run on Ubuntu.
      
      The tests fail because TLS 1.3 is being enabled for these tests. In retrospect, that *should* cause session resumption to fail, since no additional reads are being done on the socket after the handshake. I'm not quite sure yet why they pass in our build system.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23513991
      
      fbshipit-source-id: 0a401d19300d8ca7da3f9b5f8263959eac826f8c
      7d52648f
    • Yedidya Feldblum's avatar
      Some machine code check functions for terminate_with · 0887fa5e
      Yedidya Feldblum authored
      Summary:
      [Folly] Some machine code check functions for `terminate` and `terminate_with`.
      
      Demonstrates the impact of adding the extra argument.
      
      Reviewed By: magedm
      
      Differential Revision: D23523207
      
      fbshipit-source-id: c37ae61e59ca060e7e370db425cb937341bd6e09
      0887fa5e
    • Robin Cheng's avatar
      Fix simple race conditions in FunctionSchedulerTest by using atomic. · 322fdec2
      Robin Cheng authored
      Summary: This is pretty self-explanatory.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23514563
      
      fbshipit-source-id: 39b5796c742bfacc830c0154bf72bbd190501e33
      322fdec2
    • Orvid King's avatar
      Include portabilty/String.h for strndup and strcasecmp · 7aae308f
      Orvid King authored
      Summary: Windows needs it
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23497837
      
      fbshipit-source-id: e4fa8fadb3a7ac26e602ff5fbddaef0976d47b0d
      7aae308f
  9. 03 Sep, 2020 1 commit
    • Eric Niebler's avatar
      use kIsDebug instead of NDEBUG in checkNullTerminated · 340f7d54
      Eric Niebler authored
      Summary: Avoid a needless use of the preprocessor in FixedString.h by using `kIsDebug` instead of the `NDEBUG` preprocessor macro in `checkNullTerminated`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D23411248
      
      fbshipit-source-id: 78990ade25bcfa3956f917b2b285c096b76ecb09
      340f7d54