From 1a57432b66cae373a807e8d62e355c972bb0f5e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Mon, 12 May 2014 18:39:36 +0200
Subject: [PATCH] Compiler: Fixed thread context conflict.

co_wait_interpreter() doesn't swap out and in the active thread...

Fixes [LysLysKOM 20811527] (and probably [LysLysKOM 20811537] as well).
---
 src/program.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/program.c b/src/program.c
index 45fc459819..771a73aa32 100644
--- a/src/program.c
+++ b/src/program.c
@@ -54,8 +54,12 @@ static int lock_depth = 0;
 
 PMOD_EXPORT void lock_pike_compiler(void)
 {
-  while (lock_depth && (Pike_compiler_thread != th_self())) {
-    co_wait_interpreter(&Pike_compiler_cond);
+  if (lock_depth && (Pike_compiler_thread != th_self())) {
+    SWAP_OUT_CURRENT_THREAD();
+    while (lock_depth && (Pike_compiler_thread != th_self())) {
+      co_wait_interpreter(&Pike_compiler_cond);
+    }
+    SWAP_IN_CURRENT_THREAD();
   }
   lock_depth++;
   Pike_compiler_thread = th_self();
-- 
GitLab