diff options
author | Yorick van Pelt <yorick@yorickvanpelt.nl> | 2023-02-03 17:50:01 +0100 |
---|---|---|
committer | Théophane Hufschmitt <theophane.hufschmitt@tweag.io> | 2023-04-07 14:52:59 +0200 |
commit | 2c53ef1bfee7c7afea889f42b9ef13e1007ad228 (patch) | |
tree | 8aba03476e03d2d7631f596d0cb2ab45ee9bd7f3 /src/libexpr/eval.cc | |
parent | 81dfc2b01231c65137017de092c8506838fadd94 (diff) |
Disable GC inside coroutines on mac OS
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r-- | src/libexpr/eval.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 7f2065656..f7c056998 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -345,6 +345,20 @@ static Symbol getName(const AttrName & name, EvalState & state, Env & env) } +class BoehmDisableGC : public DisableGC { +public: + BoehmDisableGC() { +#if HAVE_BOEHMGC + GC_disable(); +#endif + }; + virtual ~BoehmDisableGC() override { +#if HAVE_BOEHMGC + GC_enable(); +#endif + }; +}; + static bool gcInitialised = false; void initGC() @@ -368,6 +382,12 @@ void initGC() StackAllocator::defaultAllocator = &boehmGCStackAllocator; + + /* Used to disable GC when entering coroutines on macOS */ + DisableGC::create = []() { + return std::dynamic_pointer_cast<DisableGC>(std::make_shared<BoehmDisableGC>()); + }; + /* Set the initial heap size to something fairly big (25% of physical RAM, up to a maximum of 384 MiB) so that in most cases we don't need to garbage collect at all. (Collection has a |