Summary:
In most cases user is not aware of ASAN and fiber stack problem, thus if the stackSize is specified we're not detecting ASAN and probably will crash.
And thus it doesn't seem like a good idea to make it a user responsibility to detect ASAN.
Test Plan: tests
Reviewed By: andrii@fb.com
Subscribers: alikhtarov, folly-diffs@, yfeldblum, chalfant
FB internal diff:
D2058741
Tasks:
7016680
Signature: t1:
2058741:
1431131082:
9a41eb40d756c9c7af0632f7ecd55c17d10bb189
-#include <folly/Memory.h>
-#include <folly/Optional.h>
-#include <folly/Portability.h>
-#include <folly/ScopeGuard.h>
+#include <folly/CPortability.h>
#include <folly/experimental/fibers/Baton.h>
#include <folly/experimental/fibers/Fiber.h>
#include <folly/experimental/fibers/Baton.h>
#include <folly/experimental/fibers/Fiber.h>
-#include <folly/experimental/fibers/Promise.h>
#include <folly/experimental/fibers/LoopController.h>
#include <folly/experimental/fibers/LoopController.h>
+#include <folly/experimental/fibers/Promise.h>
#include <folly/futures/Try.h>
#include <folly/futures/Try.h>
+#include <folly/Memory.h>
+#include <folly/Optional.h>
+#include <folly/Portability.h>
+#include <folly/ScopeGuard.h>
namespace folly { namespace fibers {
namespace folly { namespace fibers {
+namespace {
+
+inline FiberManager::Options preprocessOptions(FiberManager::Options opts) {
+#ifdef FOLLY_SANITIZE_ADDRESS
+ /* ASAN needs a lot of extra stack space.
+ 16x is a conservative estimate, 8x also worked with tests
+ where it mattered. Note that overallocating here does not necessarily
+ increase RSS, since unused memory is pretty much free. */
+ opts.stackSize *= 16;
+#endif
+ return opts;
+}
+
+} // anonymous
+
inline void FiberManager::ensureLoopScheduled() {
if (isLoopScheduled_) {
return;
inline void FiberManager::ensureLoopScheduled() {
if (isLoopScheduled_) {
return;
std::unique_ptr<LoopController> loopController__,
Options options) :
loopController_(std::move(loopController__)),
std::unique_ptr<LoopController> loopController__,
Options options) :
loopController_(std::move(loopController__)),
- options_(std::move(options)),
+ options_(preprocessOptions(std::move(options))),
exceptionCallback_([](std::exception_ptr eptr, std::string context) {
try {
std::rethrow_exception(eptr);
exceptionCallback_([](std::exception_ptr eptr, std::string context) {
try {
std::rethrow_exception(eptr);
class FiberManager : public ::folly::Executor {
public:
struct Options {
class FiberManager : public ::folly::Executor {
public:
struct Options {
-#ifdef FOLLY_SANITIZE_ADDRESS
- /* ASAN needs a lot of extra stack space.
- 16x is a conservative estimate, 8x also worked with tests
- where it mattered. Note that overallocating here does not necessarily
- increase RSS, since unused memory is pretty much free. */
- static constexpr size_t kDefaultStackSize{16 * 16 * 1024};
-#else
static constexpr size_t kDefaultStackSize{16 * 1024};
static constexpr size_t kDefaultStackSize{16 * 1024};
/**
* Maximum stack size for fibers which will be used for executing all the
* tasks.
/**
* Maximum stack size for fibers which will be used for executing all the
* tasks.