diff --git a/src/canvas.cpp b/src/canvas.cpp
index ba4ffededb9b..7ea755d18265 100644
--- a/src/canvas.cpp
+++ b/src/canvas.cpp
@@ -1219,9 +1219,9 @@ void mglCanvas::Pop()
 {
 	B = stack.back(); 
 #if MGL_HAVE_PTHREAD
-	pthread_mutex_lock(&m);
+	pthread_mutex_lock(&mutexStk);
 	stack.pop_back();
-	pthread_mutex_unlock(&m);
+	pthread_mutex_unlock(&mutexStk);
 #else
 #pragma omp critical(stk)
 	stack.pop_back();
