Control: tag -1 patch
On Sat, Aug 30, 2025 at 02:05:33PM +0300, Niko Tyni wrote:
> Source: fungw
> Version: 1.2.1-3.1
> Severity: important
> Tags: ftbfs forky sid upstream
> User: [email protected]
> Usertags: perl-5.42-transition
>
> This package fails to build with Perl 5.42 (currently in experimental.)
> fungw_perl.c:240:48: error: ‘PerlInterpreter’ {aka ‘struct interpreter’}
> has no member named ‘IXpv’
> The fungw code doesn't really seem to care much about which interpreter
> struct member it uses, it just needs a slot for user data. I wonder if
> modglobal hash would do:
Here's an alternative patch that does this. I tested it as far as I could,
which was running
SCRIPT=../doc/example/00_hello/hello.pl ./test_script
in the regression/ directory. It looked fine on both Perl 5.40 and
5.42. The modglobal slot seems to have been present ever since Perl
5.005 or so.
> I'm not an expert in this area though, and I don't plan to drive such a
> change myself. I assume the Perl upstream developers would be happy to
> give further advice, perhaps on the perl5-porters list.
It might still be a good idea to have somebody who actually knows Perl
internals to have a look at this. Tentatively tagging 'patch' anyway.
Hope this helps,
--
Niko
>From d2e9366a75241f9b4bdda1e383985d4c4db6b61a Mon Sep 17 00:00:00 2001
From: Niko Tyni <[email protected]>
Date: Sat, 30 Aug 2025 19:44:21 +0100
Subject: [PATCH] perl: Use the modglobal interpreter slot for context data
The Xpv slot was obsolete and removed in Perl 5.41.3:
https://github.com/Perl/perl5/commit/079a9d4ad36ef1a5b3d792b63137d406168df0e9
Use the Perl hash in the modglobal slot instead. From the perlapi
document:
"PL_modglobal" is a general purpose, interpreter global HV for use by
extensions that need to keep information on a per-interpreter basis.
In a pinch, it can also be used as a symbol table for extensions to
share data among each other. It is a good idea to use keys prefixed
by the package name of the extension that owns the data.
On threaded perls, each thread has an independent copy of this variable;
each initialized at creation time with the current value of the creating
thread's copy.
Bug-Debian: https://bugs.debian.org/1112517
---
libfungwbind/perl/fungw_perl.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/libfungwbind/perl/fungw_perl.c b/libfungwbind/perl/fungw_perl.c
index a8580bc..66f6626 100644
--- a/libfungwbind/perl/fungw_perl.c
+++ b/libfungwbind/perl/fungw_perl.c
@@ -32,7 +32,8 @@
struct, but in return the init function can't create variables or
in the interpreter before parsing a script; this workaround abuses
an unused field (as of perl 5.26.2). */
-#define perl_user_data IXpv
+#define perl_user_data_hash Imodglobal
+#define perl_user_data_key "fungw::_context"
typedef struct {
PerlInterpreter *interp;
@@ -93,7 +94,8 @@ static SV *fgws_perl_arg2sv(fgw_ctx_t *fctx, perl_ctx_t *ctx, fgw_arg_t *arg)
/* API: the script is calling an fgw function */
static XS(fgws_perl_call_fgw)
{
- perl_ctx_t *ctx = (perl_ctx_t *)my_perl->perl_user_data;
+ SV **svp = hv_fetchs(my_perl->perl_user_data_hash, perl_user_data_key, 0);
+ perl_ctx_t *ctx = INT2PTR(perl_ctx_t *, SvIV(*svp));
fgw_func_t *func;
GV *gv;
SV *func_name_sv;
@@ -237,7 +239,8 @@ static XS(fgws_perl_func_reg)
{
dXSARGS;
const char *name;
- perl_ctx_t *ctx = (perl_ctx_t *)my_perl->perl_user_data;
+ SV **svp = hv_fetchs(my_perl->perl_user_data_hash, perl_user_data_key, 0);
+ perl_ctx_t *ctx = INT2PTR(perl_ctx_t *, SvIV(*svp));
fgw_func_t *func;
SP -= items;
@@ -283,7 +286,7 @@ static int fgws_perl_init(fgw_obj_t *obj, const char *filename, const char *opts
PERL_SET_CONTEXT(ctx->interp);
perl_construct(ctx->interp);
obj->script_data = ctx;
- ctx->interp->perl_user_data = (void *)ctx;
+ hv_stores(ctx->interp->perl_user_data_hash, perl_user_data_key, newSViv(PTR2IV(ctx)));
ctx->obj = obj;
ctx->freg_delay = 1;
--
2.49.0