Re: [HACKERS] Segmentation fault in libpq

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Michal Novotny <michal(dot)novotny(at)greycortex(dot)com>
Cc: pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] Segmentation fault in libpq
Date: 2017-06-29 13:08:51
Message-ID: CAHyXU0zPsUz5qWDPpzYZ3LYOgDRdiB45RJ91pi32NvcN9xPEWQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Thu, Jun 29, 2017 at 4:01 AM, Michal Novotny
<michal(dot)novotny(at)greycortex(dot)com> wrote:
> Hi all,
>
> we've developed an application using libpq to access a table in the PgSQL
> database but we're sometimes experiencing segmentation fault on
> resetPQExpBuffer() function of libpq called from PQexecParams() with
> prepared query.
>
> PostgreSQL version is 9.6.3 and the backtrace is:
>
> Core was generated by `/usr/ti/bin/status-monitor2 -m
> /usr/lib64/status-monitor2/modules'.
> Program terminated with signal 11, Segmentation fault.
> #0 resetPQExpBuffer (str=str(at)entry=0x9f4a28) at pqexpbuffer.c:152
> 152 str->data[0] = '\0';
>
> Thread 1 (Thread 0x7fdf68de3840 (LWP 3525)):
> #0 resetPQExpBuffer (str=str(at)entry=0x9f4a28) at pqexpbuffer.c:152
> No locals.
> #1 0x00007fdf66e0333d in PQsendQueryStart (conn=conn(at)entry=0x9f46d0) at
> fe-exec.c:1371
> No locals.
> #2 0x00007fdf66e044b9 in PQsendQueryParams (conn=conn(at)entry=0x9f46d0,
> command=command(at)entry=0x409a98 "SELECT min, hour, day, month, dow, sensor,
> module, params, priority, rt_due FROM sm.cron WHERE sensor = $1 ORDER BY
> priority DESC", nParams=nParams(at)entry=1, paramTypes=paramTypes(at)entry=0x0,
> paramValues=paramValues(at)entry=0xa2b7b0, paramLengths=paramLengths(at)entry=0x0,
> paramFormats=paramFormats(at)entry=0x0, resultFormat=resultFormat(at)entry=0) at
> fe-exec.c:1192
> No locals.
> #3 0x00007fdf66e0552b in PQexecParams (conn=0x9f46d0, command=0x409a98
> "SELECT min, hour, day, month, dow, sensor, module, params, priority, rt_due
> FROM sm.cron WHERE sensor = $1 ORDER BY priority DESC", nParams=1,
> paramTypes=0x0, paramValues=0xa2b7b0, paramLengths=0x0, paramFormats=0x0,
> resultFormat=0) at fe-exec.c:1871
> No locals.
>
> Unfortunately we didn't have more information from the crash, at least for
> now.
>
> Is this a known issue and can you help me with this one?

Is your application written in C? We would need to completely rule
out your code (say, by double freeing result or something else nasty)
before assuming problem was withing libpq itself, particularly in this
area of the code. How reproducible is the problem?

merlin

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michal Novotny 2017-06-29 13:23:34 Re: Segmentation fault in libpq
Previous Message Tom Turelinckx 2017-06-29 10:31:35 Re: Bus error in formatting.c NUM_numpart_to_char (9.4.12, 9.6.3, sparc)

Browse pgsql-hackers by date

  From Date Subject
Next Message Michal Novotny 2017-06-29 13:23:34 Re: Segmentation fault in libpq
Previous Message Thomas Munro 2017-06-29 12:55:15 Re: Causal reads take II