| From: | Andrey Rachitskiy <pl0h0yp1(at)gmail(dot)com> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | andrew(at)dunslane(dot)net, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Residual cleanups for tied objects in PL/Perl |
| Date: | 2026-08-17 18:25:41 |
| Message-ID: | CAB8bMivbfPkyRhFFnqFuwPs_otaOjjFT2j1bXMr6eE6Zd95TEQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
пн, 17 авг. 2026 г. в 23:08, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Looking a bit more at the issue of standardizing our
> perl-array-scanning code, I noticed that av_len returns SSize_t
> not int, creating an overflow risk since we aren't consistent
> about assigning the result to something wider than int. This
> would only result in truncating the output not anything more
> exciting, but it's still bad. Also, it seems from looking at
> the Perl sources that they prefer to use av_count() to compute
> the loop limit. That's the same as av_len()+1 (except it returns
> Size_t), but I think that's a better habit to be in since it
> removes the risk of forgetting to add 1. So here is a patch
> that just cleans up those issues.
>
> The patch looks good to me.
Apparently av_fetch works as follows:
av_fetch returns SV** pointing to the real array element (for regular
arrays) OR mortal SV (for tied arrays)
- for regular arrays, the returned SV is NOT mortal — it lives in the
array
- for tied arrays, the returned SV MAY be mortal (temporary) because
it's created on the fly as a proxy
Calling SvGETMAGIC is critical because it:
- for regular SV: does nothing
- for magical SV: calls the FETCH method and turns the temporary "proxy"
into a real value.
--
Regards,
Rachitskiy Andrey
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrey Rachitskiy | 2026-08-17 18:41:05 | Re: Fix PGTYPESdate_fmt_asc overflow when a year does not fit "yyyy" |
| Previous Message | Peter Geoghegan | 2026-08-17 18:15:48 | Re: GIN VACUUM can corrupt internal posting tree pages |