pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Merlin Moncure <mmoncure@gmail.com>
Cc: Michal Novotny <michal.novotny@greycortex.com>
Cc: pgsql-bugs <pgsql-bugs@postgresql.org>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: [BUGS] Segmentation fault in libpq
Date: Thu, 29 Jun 2017 10:12:56 -0400
Message-ID: <14445.1498745576@sss.pgh.pa.us> (raw)
In-Reply-To: <CAHyXU0x29T3QWFDwUT6jvVhdp6dhoJC2B20XR52AR=54Em=Vpw@mail.gmail.com>
References: <b58db7a6-a80a-8db2-9ef2-5ae0fd3ca545@greycortex.com>
	<CAHyXU0zPsUz5qWDPpzYZ3LYOgDRdiB45RJ91pi32NvcN9xPEWQ@mail.gmail.com>
	<2a0f743f-4d96-30b1-8b5d-86541e8bcb34@greycortex.com>
	<CAHyXU0x29T3QWFDwUT6jvVhdp6dhoJC2B20XR52AR=54Em=Vpw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Merlin Moncure <mmoncure@gmail.com> writes:
> On Thu, Jun 29, 2017 at 8:23 AM, Michal Novotny
> <michal.novotny@greycortex.com> wrote:
>> Could you please help me based on information provided above?

> You might want to run your code through some analysis tools (for
> example, valgrind).

Yeah, that's what I was about to suggest.  pqexpbuffer.c is pretty
small and paranoid code; it's really hard to see how it could have
crashed there unless something else corrupted its data structure.
While it's always possible that the "something else" was a wild
store from elsewhere in libpq, the lack of similar reports from
others and the fact that you don't sound to be doing anything very
exotic in terms of libpq requests both weigh against that theory.
If I had to bet given this much evidence, I'd bet on a wild store
from somewhere in your application having corrupted the
conn->errorMessage before PQexecParams was entered.  C is not a
language that does much to prevent that kind of bug for you.

valgrind is not a perfect tool for finding that kind of problem,
especially if you can't reproduce the crash reliably; but at least
valgrind is readily available and easy to use, so you might as
well start there and see if it finds anything.  If you have access
to any sort of static analysis tool (eg, Coverity), that might be
more likely to help.  Or you could fall back on manual code
auditing, if the program isn't very big.

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (11+ messages)  latest in thread

Message-ID: <14445.1498745576@sss.pgh.pa.us>
Permalink:  ../14445.1498745576@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/14445.1498745576@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mmoncure@gmail.com, michal.novotny@greycortex.com, pgsql-hackers@postgresql.org
  Subject: Re: [BUGS] Segmentation fault in libpq
  In-Reply-To: <14445.1498745576@sss.pgh.pa.us>
  References: <b58db7a6-a80a-8db2-9ef2-5ae0fd3ca545@greycortex.com> <CAHyXU0zPsUz5qWDPpzYZ3LYOgDRdiB45RJ91pi32NvcN9xPEWQ@mail.gmail.com> <2a0f743f-4d96-30b1-8b5d-86541e8bcb34@greycortex.com> <CAHyXU0x29T3QWFDwUT6jvVhdp6dhoJC2B20XR52AR=54Em=Vpw@mail.gmail.com> <14445.1498745576@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox