[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: HV and SV problem
From: |
Gavin Smith |
Subject: |
Re: HV and SV problem |
Date: |
Fri, 6 Jun 2025 19:50:29 +0100 |
On Fri, Jun 06, 2025 at 07:27:56PM +0100, Gavin Smith wrote:
> To explain the problem another way, I believe that if you had XS code like:
>
> HV *hv = newHV ();
> SV *sv = newSViv(7);
> hv_store (hv, "foo", strlen ("foo"), sv, 0);
> hv_store (hv, "bar", strlen ("bar"), sv, 0);
>
> and then, in Perl code, did
>
> $hv->{'foo'} = 8;
>
> then $hv->{'bar'} would also change from 7 to 8. (I haven't tested this.)
Confirmed:
diff --git a/tta/perl/Texinfo/Convert/Plaintext.pm
b/tta/perl/Texinfo/Convert/Plaintext.pm
index 0192b3c5c3..2b4d11bbdc 100644
--- a/tta/perl/Texinfo/Convert/Plaintext.pm
+++ b/tta/perl/Texinfo/Convert/Plaintext.pm
@@ -516,6 +516,12 @@ sub converter_initialize($)
{
my $self = shift;
+ my $dodgy_hash = Texinfo::Convert::Paragraph::dodgy_hash();
+ warn "foo: ", $dodgy_hash->{'foo'}, "\n";
+ $dodgy_hash->{'foo'} = 19;
+ warn "bar: ", $dodgy_hash->{'bar'}, "\n";
+ die;
+
%{$self->{'ignored_commands'}} = %ignored_commands;
foreach my $format (keys(%format_raw_commands)) {
diff --git a/tta/perl/XSTexinfo/XSParagraph.xs
b/tta/perl/XSTexinfo/XSParagraph.xs
index 1ba5ebe379..df532dcb26 100644
--- a/tta/perl/XSTexinfo/XSParagraph.xs
+++ b/tta/perl/XSTexinfo/XSParagraph.xs
@@ -24,6 +24,18 @@ MODULE = Texinfo::Convert::Paragraph PACKAGE =
Texinfo::Convert::Paragraph PREFI
PROTOTYPES: ENABLE
+HV *
+xspara_dodgy_hash (...)
+ CODE:
+ HV *hv = newHV ();
+ SV *sv = newSViv(7);
+ hv_store (hv, "foo", strlen ("foo"), sv, 0);
+ hv_store (hv, "bar", strlen ("bar"), sv, 0);
+ RETVAL = hv;
+ OUTPUT:
+ RETVAL
+
+
void
xspara_set_state (int state)
$ ./texi2any.pl ../../doc/info-stnd.texi
foo: 7
bar: 19
Died at ../perl/Texinfo/Convert/Plaintext.pm line 523.
We set 'foo', but 'bar' changed as well.
- Duplicate variable use in Texinfo/ManipulateTree.pm, Gavin Smith, 2025/06/04
- Re: Duplicate variable use in Texinfo/ManipulateTree.pm, Patrice Dumas, 2025/06/04
- Re: Duplicate variable use in Texinfo/ManipulateTree.pm, Gavin Smith, 2025/06/05
- Re: Duplicate variable use in Texinfo/ManipulateTree.pm, Patrice Dumas, 2025/06/05
- HV and SV problem, Gavin Smith, 2025/06/06
- Re: HV and SV problem,
Gavin Smith <=
- Re: HV and SV problem, Gavin Smith, 2025/06/06
- Re: HV and SV problem, Patrice Dumas, 2025/06/07
- Re: HV and SV problem, Patrice Dumas, 2025/06/07
- Re: HV and SV problem, Gavin Smith, 2025/06/07
- Re: HV and SV problem, Gavin Smith, 2025/06/07