aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
authorYorick van Pelt <yorick@yorickvanpelt.nl>2023-02-03 17:50:01 +0100
committerYorick van Pelt <yorick@yorickvanpelt.nl>2023-03-01 13:55:41 +0100
commiteaeb994d8b9d2152e076897bf430c8ac205d3d1a (patch)
tree48394e491b460ef1946c1d4075c46bbf77300cf8 /src/libexpr/eval.cc
parent0fd8f542a8ddb303f589ff6ca3343f36e3a783c0 (diff)
Disable GC inside coroutines on mac OS
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 3e37c7f60..a5a198926 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -326,6 +326,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()
@@ -349,6 +363,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