From 78f43036056af97e4b7556377cfdb68969aab8d4 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Mon, 20 Jan 2014 12:03:15 +0000 Subject: [PATCH] thrreads::shared: LEAVE in BOOT had wrong context In Perl_sharedsv_init() - which is called from the threads::shared BOOT code - it creates a new shared interpreter, then tries to undo the ENTER done as the last step of the perl_construct(PL_sharedsv_space) step, with a LEAVE. But the LEAVE was being done in the context of the caller interpreter rather than the shared one. See the thread beginning <52D528FE.20701@havurah-software.org> --- dist/threads-shared/shared.xs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dist/threads-shared/shared.xs b/dist/threads-shared/shared.xs index 0d1f1eb..f59a82a 100644 --- a/dist/threads-shared/shared.xs +++ b/dist/threads-shared/shared.xs @@ -1247,9 +1247,11 @@ void Perl_sharedsv_init(pTHX) { dTHXc; - /* This pair leaves us in shared context ... */ PL_sharedsv_space = perl_alloc(); perl_construct(PL_sharedsv_space); + /* The pair above leaves us in shared context (what dTHX would get), + * but aTHX still points to caller context */ + aTHX = PL_sharedsv_space; LEAVE; /* This balances the ENTER at the end of perl_construct. */ PERL_SET_CONTEXT((aTHX = caller_perl)); recursive_lock_init(aTHX_ &PL_sharedsv_lock); -- 2.7.4