1. 10 May, 2016 9 commits
    • Kyle Nekritz's avatar
      Add additional ALPN mismatch tests. · c76ee315
      Kyle Nekritz authored
      Reviewed By: siyengar
      
      Differential Revision: D3264727
      
      fbshipit-source-id: fb10558096e73a3cbb6f2fb93296524c0206910d
      c76ee315
    • Faidon Liambotis's avatar
      Fix a few typos all over the code · f7f9e64e
      Faidon Liambotis authored
      Summary:
      These are pretty trivial. Debian's lint tool (lintian) warns about those
      in its verbose mode, and since we saw them when packaging for Debian, we
      thought of fixing them and forwarding them upstream.
      Closes https://github.com/facebook/folly/pull/345
      
      Reviewed By: Orvid
      
      Differential Revision: D2769801
      
      Pulled By: elliottneilclark
      
      fbshipit-source-id: ad37cc53792f21aae6558ba256f20cb56c6caab5
      f7f9e64e
    • Jaak Ristioja's avatar
      docs/Overview.md: Fixed 2 hyperlinks. · 119aae2d
      Jaak Ristioja authored
      Summary:
      These didn't work properly in GitHub.
      Closes https://github.com/facebook/folly/pull/375
      
      Differential Revision: D3281872
      
      Pulled By: elliottneilclark
      
      fbshipit-source-id: b5398267ff5856bb6a7c4a3b963ae5cb47859bc3
      119aae2d
    • Lucian Grijincu's avatar
      folly: ubsan: disable integer overflow tests in Histogram · 9dd251b3
      Lucian Grijincu authored
      Summary:
      It would be nice to fix, but it's going to be easier to do when folly
      support is for GCC>=5 which adds `__builtin_add_overflow`.
      
      For now disable the check as the Histgram code handles overflow
      correctly and has tests for these cases.
      
      Fixes need to be done for both float and integer types as Histogram is used with both.
      
      Reviewed By: meyering
      
      Differential Revision: D3280260
      
      fbshipit-source-id: 56e524c517566a4547346859be7770eda2acee96
      9dd251b3
    • Lucian Grijincu's avatar
      folly: ubsan: cast to unsigned to avoid negative-left-shift · 6c4dfb8a
      Lucian Grijincu authored
      Summary:
      The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated
        bits are filled with zeros.
      
        If E1 has a signed type and non-negative value, and E1 × 2E2 is
        representable in the result type, then that is the resulting value;
        otherwise, the behavior is undefined.
      
      The code assumed the signed left shift worked like an unsigned left
      shift, so make that explicit.
      
      Reviewed By: meyering
      
      Differential Revision: D3280325
      
      fbshipit-source-id: 178b95ee36b7a1126a79bb825c2ad2ffa6fa9464
      6c4dfb8a
    • Lucian Grijincu's avatar
      folly: ubsan: fix "reference binding to null pointer of type 'char'" · c03fd9b7
      Lucian Grijincu authored
      Summary:
      third-party-buck/build/libgcc/include/c++/4.9.x/bits/stl_vector.h:866:9: runtime error: reference binding to null pointer of type 'char'
      
      ```
      Breakpoint 2, 0x0000000000494894 in __ubsan_handle_type_mismatch_abort ()
      (gdb) bt
      ```
      
      Reviewed By: meyering, yfeldblum
      
      Differential Revision: D3279234
      
      fbshipit-source-id: 63a761587e5b3f79ece09fc99b9a593da0e44b75
      c03fd9b7
    • Christopher Dykes's avatar
      Deal with some oddities of MSVC's preprocessor · dc8c21a9
      Christopher Dykes authored
      Summary: MSVC's preprocessor is different in how it deals with passing arguments expanded from `__VA_ARGS__`, so we have to add a stub to force it to expand the arguments.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3256328
      
      fbshipit-source-id: 551434833d40e55498a9ab352eb74acdfd094835
      dc8c21a9
    • Christopher Dykes's avatar
      Fix detection of std::make_unique under MSVC · d65a097e
      Christopher Dykes authored
      Summary: MSVC doesn't define `__cplusplus` as a high enough value to trigger this, so add an explicit check for MSVC instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3271647
      
      fbshipit-source-id: a1e5a5a7eb75dce066dfc7fae8b2086880dc4c3d
      d65a097e
    • Lucian Grijincu's avatar
      folly: ubsan: &v[0] is undefined if v.empty() · 70cab78c
      Lucian Grijincu authored
      Summary:
      before:
      
        [ RUN      ] RangeFunc.Vector
        bits/stl_vector.h:866:9: runtime error: reference binding to null pointer of type 'int'
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3279253
      
      fbshipit-source-id: 957a8ec050f5c3b27febf7e6cd16ad1d307da169
      70cab78c
  2. 09 May, 2016 6 commits
    • Jim Meyering's avatar
      folly test: fix typo in RandomDataHolder::RandomDataHolder · 42186195
      Jim Meyering authored
      Summary:
      Running the folly/io/test:compression_test with a UBSAN-enabled binary would fail with this:
      
        folly/io/test/CompressionTest.cpp:96:36: runtime error: shift exponent 16777216 is too large for 64-bit type 'size_t' (aka 'unsigned long')
      
      That exposed the unwanted left-shift.
      That made it so the actual "start" offsets were in the range [0..numThreads-1], rather than being
      e.g., with numThreads == 8, [0, 16777216, 33554432, ...].  Oops.
      
      Reviewed By: luciang
      
      Differential Revision: D3277606
      
      fbshipit-source-id: 4bc48f84b0065de070b62a810f08b96e36ea7136
      42186195
    • Christopher Dykes's avatar
      Include <nmmintrin.h> in GroupVarint.h · 96fd8071
      Christopher Dykes authored
      Summary: Because it is the standard (well, Intel's standard) location for __m128i, and GCC, Clang, MSVC and ICC all implement it in that location.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3270872
      
      fbshipit-source-id: fa0f0410670cdb310e656ca55ee0f568ca5ee06f
      96fd8071
    • Lucian Grijincu's avatar
      folly: fbvector: ubsan: avoid memcpy(dest, nullptr, 0) · d45588bd
      Lucian Grijincu authored
      Reviewed By: meyering
      
      Differential Revision: D3277138
      
      fbshipit-source-id: 7050d18c256ac15c8122d4af59aa31208b1466fd
      d45588bd
    • Christopher Dykes's avatar
      Explicitly reference folly::detail · 5a081994
      Christopher Dykes authored
      Summary: Due to some fun with the order MSVC does name lookup in templates, it ends up complaining that these are ambigious between folly::detail and folly::recordio_helpers::detail. The solution is to simply reference folly::detail explicitly.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3271606
      
      fbshipit-source-id: e599ad8d8fe33b1e4ec0b838ddb5dfacfdf60159
      5a081994
    • Christopher Dykes's avatar
      Fix a few issues in the portability headers · ab239ddf
      Christopher Dykes authored
      Summary:
      This fixes a few issues in the portability headers for MSVC.
      Not entirely sure how I managed to cause these in the first place, but this fixes them anyways.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3271859
      
      fbshipit-source-id: 11a5d35246f29112563ee9079525aa37ced206ff
      ab239ddf
    • Philip Pronin's avatar
      Reverted commit D3265572 · 0759dee4
      Philip Pronin authored
      Summary:
      I would switch these to just use the intrinsic functions, but GCC 4.8 doesn't support them.
      MSVC supports the intrinsics, which is the primary reason for the switch.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3265572
      
      fb-gh-sync-id: 3268f90d5234bdf77b3579504efd3dcd43f38aff
      fbshipit-source-id: 3268f90d5234bdf77b3579504efd3dcd43f38aff
      0759dee4
  3. 07 May, 2016 1 commit
    • Andrii Grynenko's avatar
      Don't re-throw exceptions from default FiberManager exception handler · 90678e67
      Andrii Grynenko authored
      Summary: It's very unlikely that caller will handle such exceptions and FiberManager can proceed even if one task failed. DFATAL will ensure we still fail on such exceptions in debug builds.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3273573
      
      fb-gh-sync-id: 55eba19c16429a3c89a2fdf5363fd4b55b3998a2
      fbshipit-source-id: 55eba19c16429a3c89a2fdf5363fd4b55b3998a2
      90678e67
  4. 06 May, 2016 5 commits
    • Andrii Grynenko's avatar
      Don't throw on late singleton registration · 8d90d07e
      Andrii Grynenko authored
      Summary: Having singleton registered after registrationComplete() is called is not a hard failure. Replacing exception with ERROR, since we probably still want to avoid such situation.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3266376
      
      fb-gh-sync-id: 8130d279775348c835265987c95189bd3d8106f9
      fbshipit-source-id: 8130d279775348c835265987c95189bd3d8106f9
      8d90d07e
    • Christopher Dykes's avatar
      Use intrinsics rather than inline assembly where possible · ceaca5b0
      Christopher Dykes authored
      Summary:
      I would switch these to just use the intrinsic functions, but GCC 4.8 doesn't support them.
      MSVC supports the intrinsics, which is the primary reason for the switch.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3265572
      
      fb-gh-sync-id: f12d16b8f64cf48adcb97958d7ae88d56689a96f
      fbshipit-source-id: f12d16b8f64cf48adcb97958d7ae88d56689a96f
      ceaca5b0
    • Christopher Dykes's avatar
      Create the stdio.h portability header · fb8565dd
      Christopher Dykes authored
      Summary: Windows doesn't define a couple of functions.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2990676
      
      fb-gh-sync-id: 1a1354bd7976cb8b4747436d6907d65210ba506c
      fbshipit-source-id: 1a1354bd7976cb8b4747436d6907d65210ba506c
      fb8565dd
    • Haijun Zhu's avatar
      Bind to a random file in unix domain socket test · 089f5522
      Haijun Zhu authored
      Summary:
      test console reports "address already in use" failure so add some
      randomness to it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3265329
      
      fb-gh-sync-id: a825cce787394783bb8d18d92385d2497b163385
      fbshipit-source-id: a825cce787394783bb8d18d92385d2497b163385
      089f5522
    • Christopher Dykes's avatar
      Create the unistd.h portability header · af77aab7
      Christopher Dykes authored
      Summary: Windows doesn't have it, and it's used in a lot of places.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D2997499
      
      fb-gh-sync-id: fbf8f5f087b8f39197d5bf2177e4d34efd74631f
      fbshipit-source-id: fbf8f5f087b8f39197d5bf2177e4d34efd74631f
      af77aab7
  5. 05 May, 2016 4 commits
    • Andrii Grynenko's avatar
      Allow optional atfork hook for singleton destruction · a9c78aa8
      Andrii Grynenko authored
      Summary: Grouping all folly::ThreadLocal atfork hooks in one. This allows proper ordering between folly::ThreadLocal hooks and hooks added by other libraries (we always want folly::ThreadLocal hooks to be registered first).
      
      Reviewed By: ericniebler
      
      Differential Revision: D3262666
      
      fb-gh-sync-id: 1aa928b9ddd484580f4a4a7b320e9e64164bb04a
      fbshipit-source-id: 1aa928b9ddd484580f4a4a7b320e9e64164bb04a
      a9c78aa8
    • Andrii Grynenko's avatar
      Implement LoopKeepAlive for EventBase · 2d2aed32
      Andrii Grynenko authored
      Summary: LoopKeepAlive can be useful to tell EventBase, that loop() shouldn't return even if there are no events registered, because some tasks will later be added via runInEventBaseThread. While at least one LoopKeepAlive is alive - EventBase::loop() behaves like EventBase::loopForever().
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3261706
      
      fb-gh-sync-id: d91424d3d12cae11abd72cffdbd57f136f628dae
      fbshipit-source-id: d91424d3d12cae11abd72cffdbd57f136f628dae
      2d2aed32
    • Andrii Grynenko's avatar
      Allow adding tasks to TaskIterator dynamically · 93db3df4
      Andrii Grynenko authored
      Reviewed By: yfeldblum
      
      Differential Revision: D3244669
      
      fb-gh-sync-id: 73fa4ecb0432a802e67ef922255a896d96f32374
      fbshipit-source-id: 73fa4ecb0432a802e67ef922255a896d96f32374
      93db3df4
    • Michael Lee's avatar
      Switch gflags to portability/GFlags.h · 4598dd70
      Michael Lee authored
      Summary:
      There are two places that still includes gflags/gflags.h:
      portability/GFlags.h and futures/exercises/Koan.h. Also removing
      gflags entirely from a couple of places which never reference it at
      all.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3203187
      
      fb-gh-sync-id: e7725fbf2c4b3c475c0035e1b0e8c6e1227f277f
      fbshipit-source-id: e7725fbf2c4b3c475c0035e1b0e8c6e1227f277f
      4598dd70
  6. 04 May, 2016 13 commits
    • Christopher Dykes's avatar
      Create the stdlib.h portability header · 2d969487
      Christopher Dykes authored
      Summary: Windows doesn't have these functions under these names, so be nice to the code using it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3003641
      
      fb-gh-sync-id: 1657545af6975c96aea4a48c359250828b5921e0
      fbshipit-source-id: 1657545af6975c96aea4a48c359250828b5921e0
      2d969487
    • Christopher Dykes's avatar
      Create the fcntl.h portability header · 4e0a5b3a
      Christopher Dykes authored
      Summary: Windows has it, but all it does is define a few constants.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3002161
      
      fb-gh-sync-id: a719faf391125522b2cb21471a56e8a9fe894225
      fbshipit-source-id: a719faf391125522b2cb21471a56e8a9fe894225
      4e0a5b3a
    • Eric Niebler's avatar
      rearrange folly::Function so that its template arguments are deducable. · 62b1d047
      Eric Niebler authored
      Summary:
      `folly::Function` was an alias to a more complex type with template arguments that could not be deduced. For example, the call to `foo` below was failing to compile.
      
      ```
      template <class R, class... As>
      void foo(folly::Function<R(As...)> f) {
      }
      
      int main() {
        foo( folly::Function<void(int)>{ [](int i){} } );
      }
      ```
      
      Rearrange the code so that folly::Function is no longer an alias, thus making its template arguments deducable.
      
      Reviewed By: luciang, spacedentist
      
      Differential Revision: D3256130
      
      fb-gh-sync-id: fb403e48d161635b3b7f36e53b1679eb46cbfe7f
      fbshipit-source-id: fb403e48d161635b3b7f36e53b1679eb46cbfe7f
      62b1d047
    • Andrii Grynenko's avatar
      folly::Future integration with Python · a6fd9a69
      Andrii Grynenko authored
      Summary:
      This diff implements two functions which can be used to bridge C++ asynchronous APIs with Python.
      1. getExecutor(event_loop) allows extracting a folly::Executor-compatible object from Python event_loop.
      2. wrapFuture wraps any folly::Future object in a Python Future object.
      
      Reviewed By: ambv
      
      Differential Revision: D2878731
      
      fb-gh-sync-id: 83628b6b24d6039999f88c5de441e41064b2417e
      fbshipit-source-id: 83628b6b24d6039999f88c5de441e41064b2417e
      a6fd9a69
    • Christopher Dykes's avatar
      Fix the weak references to JEMalloc under MSVC · 9a47ba11
      Christopher Dykes authored
      Summary: While the previous version did compile, it would generate warnings about symbols being defined in multiple places.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3255815
      
      fb-gh-sync-id: 72f5079a3973a04bdc0b469b97ba46181e40353b
      fbshipit-source-id: 72f5079a3973a04bdc0b469b97ba46181e40353b
      9a47ba11
    • Christopher Dykes's avatar
      Implement __builtin_ctzll for MSVC · f79d6393
      Christopher Dykes authored
      Summary: MSVC doesn't have it, but Folly uses it, so implement it in the Builtins portability header.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3256123
      
      fb-gh-sync-id: fd9ea1b6098d97cf1fde4732905bae9bde8cd8ad
      fbshipit-source-id: fd9ea1b6098d97cf1fde4732905bae9bde8cd8ad
      f79d6393
    • Christopher Dykes's avatar
      Don't initialize kDestroyWaitTime in-class · 32e0fe56
      Christopher Dykes authored
      Summary: MSVC doesn't like it when you try to initialize a static in-class non-primitive constexpr member. It was only used in one place, so stick the definition in that function instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3255178
      
      fb-gh-sync-id: e4a862a2662c4f5376c19fc52827cb2953f01e52
      fbshipit-source-id: e4a862a2662c4f5376c19fc52827cb2953f01e52
      32e0fe56
    • Christopher Dykes's avatar
      Use std::thread::id in Fiber rather than a syscall · 7d3bbfee
      Christopher Dykes authored
      Summary: syscall() doesn't exist on Windows, but std::thread::id is standardized, and can do what we need it for, so use it instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3256064
      
      fb-gh-sync-id: efddac82c117ccd8a53c8c93248529000b4326a5
      fbshipit-source-id: efddac82c117ccd8a53c8c93248529000b4326a5
      7d3bbfee
    • Christopher Dykes's avatar
      Don't attempt to implicitly convert an atomic<T> to bool · 36f174f9
      Christopher Dykes authored
      Summary: MSVC doesn't like it, so the other uses were changed to .load() explicitly a while back, but this use has been added since then.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3255261
      
      fb-gh-sync-id: 11d49902eb3ef7113a7c57cc760353554a487496
      fbshipit-source-id: 11d49902eb3ef7113a7c57cc760353554a487496
      36f174f9
    • Marcus Holland-Moritz's avatar
      Unpoison stack memory before deallocation · 6959fbe7
      Marcus Holland-Moritz authored
      Summary:
      This is a workaround (maybe even the correct fix if it turns out that ASan
      can't detect this FP case) for the problem described in
      
        https://llvm.org/bugs/show_bug.cgi?id=27627
      
      where a memory region previously allocated by a fiber stack can overlap with
      the region of an mmap'd file. Accessing parts of the mmap'd file close to
      the stack region will trigger a false positive ASan error.
      
      This change makes sure each fiber explicitly unpoisons its stack memory by
      calling __asan_unpoison_memory_region in an ASan-enabled build.
      
      Reviewed By: yhfung
      
      Differential Revision: D3257924
      
      fb-gh-sync-id: 484062e80af67dfd39d2eaf3cbb52fa3483924eb
      fbshipit-source-id: 484062e80af67dfd39d2eaf3cbb52fa3483924eb
      6959fbe7
    • Pavlo Kushnir's avatar
      Optimize copy/move · 1c523f26
      Pavlo Kushnir authored
      Summary: this diff provides methods that allow to avoid temporaries while cloning IOBufs. Also optimizes move constructor a bit - there is no need to call `decrementRefCount`, check for self assignment, etc.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3250456
      
      fb-gh-sync-id: 32b0180c28f36151c6786dba6f511b491b224200
      fbshipit-source-id: 32b0180c28f36151c6786dba6f511b491b224200
      1c523f26
    • Yedidya Feldblum's avatar
      Let via take a functor by universal reference · d0ed1890
      Yedidya Feldblum authored
      Summary:
      [Folly] Let `via` take a functor by universal reference.
      
      And perfect-forward the functor to the call to `then`.
      
      Reviewed By: fugalh
      
      Differential Revision: D3255684
      
      fb-gh-sync-id: 1b46a70fb9de88d21d785c0ce4d9dd3078829f13
      fbshipit-source-id: 1b46a70fb9de88d21d785c0ce4d9dd3078829f13
      d0ed1890
    • Christopher Dykes's avatar
      Create the sockets portability header · f253e1e4
      Christopher Dykes authored
      Summary: The one header that doesn't split well. This is the last piece of the portability headers for Windows and is also the piece that has had the most thought put into it's design so-as to be as unintrusive as possible.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3046525
      
      fb-gh-sync-id: 761a5e359bc130b95585608ee18fda94a30dae2c
      fbshipit-source-id: 761a5e359bc130b95585608ee18fda94a30dae2c
      f253e1e4
  7. 03 May, 2016 2 commits
    • Marcelo Juchem's avatar
      More useful logging upon failed AsyncServerSocket::bind() · 0d8402e0
      Marcelo Juchem authored
      Summary: `AsyncServerSocket::bind()` would not give information like port or family name when failing to bind a socket. This diff addresses that by including this information in the exception. Two additional helper methods were added to `SocketAddress` to retrieve both the port and the family name from a `sockaddr` structure.
      
      Reviewed By: ckwalsh, yfeldblum
      
      Differential Revision: D3249778
      
      fb-gh-sync-id: 4edb28af5c211b7bf8d525b40844a5b0b6261e07
      fbshipit-source-id: 4edb28af5c211b7bf8d525b40844a5b0b6261e07
      0d8402e0
    • Sven Over's avatar
      fix passing move-only types to via(Executor*, Func) · 32623e8e
      Sven Over authored
      Summary: This diff fixes a problem with passing move-only types to folly::via.
      
      Reviewed By: ericniebler
      
      Differential Revision: D3254906
      
      fb-gh-sync-id: 8a9c703a8db0ccf20b9fb4fe9b80ad6cdcb3e388
      fbshipit-source-id: 8a9c703a8db0ccf20b9fb4fe9b80ad6cdcb3e388
      32623e8e