Tags: kris-jusiak/folly
Tags
Fix include order and grouping in folly - 13/13 Summary: All changes were automated Reviewed By: Orvid Differential Revision: D25507592 fbshipit-source-id: 3ce36732a2d1c691087fbd95c3e87f554f4d8d98
folly: utf8ToCodePoint: enforce max valid code point is U+10FFFF - re… …turn U+FFFD / throw for well-formed UTF-8 encoded values that are larger than the max code point Summary: UTF-8 can encode large numbers, but Unicode code points are only defined up to `U+10FFFF`. For example: - the 4B UTF-8 encoding `"\xF6\x8D\x9B\ xBC"` (bits: `11110110 10001101 10011011 10111100`) is a valid UTF-8 encoding - but the encoded value is `U+18D6 (https://github.com/facebook/folly/commit/d40182262d41679cab28f6be7366cc5ff901683b)FC` which is larger than `U+10FFFF` With `opts.skip_invalid_utf8 = true;` `json::serialize` should have returned `"\ufffd"` since it the input is invalid, but due to a bug in `utf8ToCodePoint` it returned the incorrect `"\"\xF6\x8D\x9B\xBC\""`. Update `utf8ToCodePoint` to also reject 4 byte UTF-8 encoded values larger than the max Unicode code point (`U+10FFFF`). Reviewed By: luciang Differential Revision: D25275722 fbshipit-source-id: e7daeea834a0c5323923a5451a2565ceff5e4734
Adding yaml-cpp fboss code for oss Summary: Added yaml-cpp library to the fboss OSS build Reviewed By: shri-khare Differential Revision: D25126509 fbshipit-source-id: 1e88150dbf8c96a5ac696e003265dc1f14bec105
Adding yaml-cpp fboss code for oss Summary: Added yaml-cpp library to the fboss OSS build Reviewed By: shri-khare Differential Revision: D25126509 fbshipit-source-id: 1e88150dbf8c96a5ac696e003265dc1f14bec105
Add API to AsyncServerSocket that allows potentially stale connection… …s to be dropped Summary: Added a timestamp to `AsyncServerSocket::QueueMessage` so that `NotificationQueue` can ignore new connection messages which are deemed *expired*. Expired messages represent sockets which have *probably* timed out already. The TTL is configured per `AsyncServerSocket` instance and is applied to all future messages that are queued by it. By default, messages do not expire. This can be configured with `AsyncServerSocket::setQueueTimeout`. Reviewed By: andriigrynenko Differential Revision: D24667870 fbshipit-source-id: 0f9d6c235627393d964e280a0d5956676010c7aa
Fix missing #include <limits> (facebook#1482) Summary: Hello, The compilation with the HEAD of gcc 11 fails: ``` FAILED: CMakeFiles/folly_base.dir/folly/TimeoutQueue.cpp.o g++ ... -c ../folly/TimeoutQueue.cpp ../folly/TimeoutQueue.cpp: In member function 'int64_t folly::TimeoutQueue::nextExpiration() const': ../folly/TimeoutQueue.cpp:39:32: error: 'numeric_limits' is not a member of 'std' 39 | timeouts_.empty() ? std::numeric_limits<int64_t>::max() | ^~~~~~~~~~~~~~ ../folly/TimeoutQueue.cpp:39:54: error: expected primary-expression before '>' token 39 | timeouts_.empty() ? std::numeric_limits<int64_t>::max() | ^ ../folly/TimeoutQueue.cpp:39:57: error: '::max' has not been declared 39 | timeouts_.empty() ? std::numeric_limits<int64_t>::max() | ^~~ ../folly/TimeoutQueue.cpp:39:57: note: suggested alternatives: In file included from /opt/1A/toolchain/x86_64-v21.0.8/include/c++/11.0.0/functional:65, from ../folly/TimeoutQueue.h:31, from ../folly/TimeoutQueue.cpp:17: /opt/1A/toolchain/x86_64-v21.0.8/include/c++/11.0.0/bits/stl_algo.h:3464:5: note: 'std::max' 3464 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ ``` It is nothing to fix. Regards, Laurent Pull Request resolved: facebook#1482 Reviewed By: yfeldblum Differential Revision: D24757105 Pulled By: Orvid fbshipit-source-id: 8a5382edbe5b7c11cace5a1cd4c0645dfd2a9d37
Disable an exception-throw stress test for DistributedMutex under TSAN Summary: This test inexplicably aborts when ran under TSAN. TSAN reports a read-write race where the exception is freed by the lock-holder / combiner thread and read concurrently by the thread that requested the combine operation. TSAN reports a similar read-write race for this code as well https://gist.github.com/aary/a14ae8d008e1d48a0f2d61582209f217 (copied below). Which is easier to verify as being correct. Though this does not conclusively prove that this test and implementation are race-free, the above repro combined with error-free stress runs of this test under other modes (optimized builds with and without both ASAN and UBSAN) give us a high signal at TSAN's error being a false-negative. So disabling it for now until some point in the future where TSAN stops reporting this as a false-negative ``` namespace { struct Storage { std::atomic<std::uint64_t> futex_{0}; std::atomic<std::uint64_t> next_; std::aligned_storage_t<48, 8> storage_; }; template <typename Waiter> void transferCurrentException(Waiter* waiter) { assert(std::current_exception()); new (&waiter->storage_) std::exception_ptr{std::current_exception()}; waiter->futex_.store(1, std::memory_order_release); } template <template <typename> class Atom = std::atomic> void concurrentExceptionPropagationStress( int, std::chrono::milliseconds) { auto exceptions = std::vector<std::unique_ptr<Storage>>{}; exceptions.resize(1000000); for (auto i = std::size_t{0}; i < exceptions.size(); ++i) { exceptions[i] = std::make_unique<Storage>(); } auto throwing = std::function<void(std::uint64_t)>{[&](auto counter) { if (counter % 2) { throw std::runtime_error{folly::to<std::string>(counter)}; } }}; std::cout << "Started test" << std::endl; auto writer = std::thread{[&]() { for (auto i = std::size_t{0}; i < exceptions.size(); ++i) { try { std::this_thread::yield(); throwing(i); } catch (...) { transferCurrentException(exceptions.at(i).get()); continue; } exceptions.at(i)->futex_.store(2, std::memory_order_release); } }}; auto reader = std::thread{[&]() { for (auto i = std::size_t{0}; i < exceptions.size(); ++i) { auto value = std::uint64_t{}; while (!(value = exceptions.at(i)->futex_.load(std::memory_order_acquire))) {} if (value == 1) { try { auto buf = reinterpret_cast<std::exception_ptr*>(&exceptions.at(i)->storage_); auto ex = folly::launder(buf); auto copy = std::move(*ex); ex->exception_ptr::~exception_ptr(); std::rethrow_exception(std::move(copy)); } catch (std::exception& exc) { assert(folly::to<std::uint64_t>(exc.what()) == i); } } } }}; reader.join(); writer.join(); } } // namespace ``` Reviewed By: yfeldblum Differential Revision: D24653383 fbshipit-source-id: 3ce166766eb42b22ec7b8cfaf8d31ca53580ff9e
Use static_cast instead of function-style cast in ConstexprMath.h Summary: Some llvm toolsets mis-parse the function-like C-style casts in ConstexprMath.h as function declarations, resulting in strange compiler errors. Prefer `static_cast` to eliminate the ambiguity. Note: We cannot use brace-initialization syntax, because that would error on narrowing conversions. Reviewed By: ispeters, Mizuchi Differential Revision: D24463342 fbshipit-source-id: 5d5aabb08cd20e91a1a5f5460cc4505cafb3cdfc
Add `midpoint()` calculation to folly 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
Add support for UDP RX timestamps Summary: Add support for UDP RX timestamps Reviewed By: mjoras Differential Revision: D24146914 fbshipit-source-id: 381839fc5402f13e428364c47c5752473acda6af
PreviousNext