Re: empty array case in plperl_ref_from_pg_array not handled correctly

From: Oleksii Kliukin <alexk(at)hintbits(dot)com>
To: Alex Hunsaker <badalex(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Álvaro Herrera <alvherre(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: empty array case in plperl_ref_from_pg_array not handled correctly
Date: 2016-03-08 21:16:48
Message-ID: 36414960-17FB-428C-B755-EA3231BAFA0B@hintbits.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> On 08 Mar 2016, at 10:11, Alex Hunsaker <badalex(at)gmail(dot)com> wrote:
>
>
>
> On Mon, Mar 7, 2016 at 11:32 PM, Andres Freund <andres(at)anarazel(dot)de <mailto:andres(at)anarazel(dot)de>> wrote:
> Hi,
>
> Per the new valgrind animal we get:
>
> http://pgbuildfarm.org/cgi-bin/show_log.pl?nm=skink&dt=2016-03-08%2004%3A22%3A00
> 2016-03-08 <http://pgbuildfarm.org/cgi-bin/show_log.pl?nm=skink&dt=2016-03-08%2004%3A22%3A002016-03-08> 05:56:05.566 UTC [56de6971.723:5] LOG: statement: select plperl_sum_array('{}');
> ==1827== Invalid write of size 4
> ==1827== at 0x14E35DD1: plperl_ref_from_pg_array (plperl.c:1459)
>
>
> [ I think you may have meant to CC me not Alexey K. I'm probably the person responsible :D. ]
>
> Indeed, I think the simplest fix is to make plperl_ref_from_pg_array() return an "empty" array in that case. The attached fixes the valgrind warning for me. (cassert enabled build on master).

Looks good to me, thank you. Judging from the size in the error message it’s likely the

info->nelems[0] = items

line that caused this issue. The patch fixes it at first glance, although I have yet to make my valgrind setup on OS X working to check this for real :-)

Kind regards,
--
Oleksii

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2016-03-08 21:24:23 Re: Allowing to run a buildfarm animal under valgrind
Previous Message Fabien COELHO 2016-03-08 20:52:47 Re: extend pgbench expressions with functions