Re: HV and SV problem

2025-06-07 Thread Gavin Smith
On Sat, Jun 07, 2025 at 09:51:50AM +0200, Patrice Dumas wrote: > On Fri, Jun 06, 2025 at 07:27:55PM +0100, Gavin Smith wrote: > Indeed, that's the issue, thanks for the analysis. What confused me is > that in Perl code, it does not happens that way, but I think that it is > because the Perl scalar

Re: HV and SV problem

2025-06-07 Thread Patrice Dumas
On Sat, Jun 07, 2025 at 09:51:50AM +0200, Patrice Dumas wrote: > I found newSVsv, which seems to copy the SV, including the blessing and > the 'reference' to the HV, this could be an alternative to keeping the > HV in C and calling newRV and blessing each time a reference is needed. > I still need

Re: HV and SV problem

2025-06-07 Thread Gavin Smith
On Fri, Jun 06, 2025 at 07:27:56PM +0100, Gavin Smith wrote: > Then I suspected something was strange with the way the data structures > were constructed. I suspect it would be hard to replicate the loss without > using XS. After reading through "man perlref" again, I found the 'refaliasing' fea

Re: HV and SV problem

2025-06-07 Thread Patrice Dumas
On Fri, Jun 06, 2025 at 07:27:55PM +0100, Gavin Smith wrote: > In element_to_perl_hash, commit 359b73825d2 changed: > > - sv = newRV_inc ((SV *) e->parent->hv); > - hv_store (e->hv, "parent", strlen ("parent"), sv, HSH_parent); > + sv = SvREFCNT_inc ((SV *) e->parent->sv); > +

Re: HV and SV problem

2025-06-06 Thread Gavin Smith
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 P

Re: HV and SV problem

2025-06-06 Thread Gavin Smith
On Fri, Jun 06, 2025 at 07:27:56PM +0100, Gavin Smith wrote: > I had a breakthrough when I realised that the referenced parent element, > the $previous_ending_container->{'contents'}->[$i]->{'parent'}, was the > before_item > element that was being overwritten. What if the assignment didn't just

HV and SV problem

2025-06-06 Thread Gavin Smith
On Thu, Jun 05, 2025 at 10:45:17PM +0200, Patrice Dumas wrote: > I do not have any good idea on what more could be done to understand > what is going on. I based my investigations on commit 08c59dc0cbc36 (2025-06-05) as you said that your later commits did not fix the problem. Summary: I think I