Re: BUG #14582: ecpg crashes on SQL input

From: Euler Taveira <euler(at)timbira(dot)com(dot)br>
To: mdudley(at)gryphonsensors(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14582: ecpg crashes on SQL input
Date: 2017-03-09 14:43:50
Message-ID: CAHE3wghFXrHbJ+pkjkjLhVW=oGNLUhfuMPO3sb577ExkPUvORw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

2017-03-08 13:56 GMT-03:00 <mdudley(at)gryphonsensors(dot)com>:

> I have some SQL that crashes ecpg when I run:
>
> $ cat test.sql | /usr/pgsql-9.6/bin/ecpg -o - -
>
> I installed PostgreSQL from
> "postgresql96-server-9.6.2-2PGDG.rhel7.x86_64.rpm".
>
> There are trailing spaces on some lines in the SQL below--they are
> necessary
> in order to reproduce the crash.
>
> I reproduced the crash only with 9.6 and 9.5 (didn't try hard with other
supported versions but they don't crash -- including HEAD) with the
attached file extracted from your email (some email clients mangles your
test). The crash seems to be related to the blank line in the middle of the
above command (altough, few spaces doesn't crash the test). In a rapid
test, a line with > 40 spaces produces the crash.

> INSERT INTO xxxxxxxx_xxxxxx_xxxxx(\
> xxxxxx_xx, \
> xxxx_xxxxxxxxxxxxx_xx, \
> xxxxxx_xxxxxxxxxxx_xxx_xx,\
> xxxxxxxxxxx_xx, \
>
> xxxxxxxx_xxxxxxxx_xxxxxx_xxxxx_xx)\
> VALUES ( \
> ( SELECT x_xx FROM xxxxxxx_xxxxxx LIMIT 1 ), \
> ( SELECT xxxx_xxxxxxxxxxxxx_xx FROM xxxxxx LIMIT 1 ),
>

The backtrace is:

(gdb) bt
#0 0x00007ff67829e067 in __GI_raise (sig=sig(at)entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x00007ff67829f448 in __GI_abort () at abort.c:89
#2 0x00007ff6782dc1b4 in __libc_message (do_abort=do_abort(at)entry=1,
fmt=fmt(at)entry=0x7ff6783d1210 "*** Error in `%s': %s: 0x%s ***\n") at
../sysdeps/posix/libc_fatal.c:175
#3 0x00007ff6782e198e in malloc_printerr (action=1, str=0x7ff6783d13f8
"double free or corruption (fasttop)", ptr=<optimized out>) at malloc.c:4996
#4 0x00007ff6782e2696 in _int_free (av=<optimized out>, p=<optimized out>,
have_lock=0) at malloc.c:3840
#5 0x0000000000401a4d in cat2_str (str1=<optimized out>, str2=<optimized
out>) at preproc.y:145
#6 0x0000000000401ad2 in cat_str (count=9) at preproc.y:162
#7 0x000000000040eb80 in base_yyparse () at preproc.y:6731
#8 0x0000000000403113 in main (argc=4, argv=0x7fff016f3ff8) at ecpg.c:452

--
Euler Taveira Timbira -
http://www.timbira.com.br/
PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento
<http://www.timbira.com.br>

Attachment Content-Type Size
test3.ecpg application/octet-stream 1.3 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Meskes 2017-03-09 14:56:47 Re: BUG #14582: ecpg crashes on SQL input
Previous Message Dudley, Michael 2017-03-09 13:42:45 Re: BUG #14582: ecpg crashes on SQL input