From 495708e9d1b396ff450df15d5789b4f6c51f6ebc Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 13 Jul 2023 11:50:02 +0100 Subject: [PATCH 16/16] perl: Call PERL_SET_CONTEXT from .open method This appears to be necessary with Perl 5.38. --- plugins/perl/perl.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugins/perl/perl.c b/plugins/perl/perl.c index d3b7cede2..1d8d0c2b4 100644 --- a/plugins/perl/perl.c +++ b/plugins/perl/perl.c @@ -339,6 +339,21 @@ perl_open (int readonly) SV *sv; dSP; + /* + * From perlembed(1): + * + * "PERL_SET_CONTEXT(interp) should also be called whenever "interp" + * is used by a thread that did not create it (using either + * perl_alloc(), or the more esoteric perl_clone())." + * + * Since we may be called here from a new thread created within + * nbdkit, do this. This is necessary since Perl 5.38. It didn't + * seem to make a difference with earlier Perl, but doesn't break + * them either. + */ + + PERL_SET_CONTEXT (my_perl); + /* We check in perl_config that this callback is defined. */ ENTER; SAVETMPS; -- 2.41.0