Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQaBr-0001tD-DB for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Jun 2017 14:13:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dQaBq-0000xO-T4 for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Jun 2017 14:13:02 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dQaBp-0000ws-PO; Thu, 29 Jun 2017 14:13:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dQaBn-0001NH-BX; Thu, 29 Jun 2017 14:13:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v5TECuaa014446; Thu, 29 Jun 2017 10:12:56 -0400 From: Tom Lane To: Merlin Moncure cc: Michal Novotny , pgsql-bugs , PostgreSQL-development Subject: Re: [BUGS] Segmentation fault in libpq In-reply-to: References: <2a0f743f-4d96-30b1-8b5d-86541e8bcb34@greycortex.com> Comments: In-reply-to Merlin Moncure message dated "Thu, 29 Jun 2017 08:32:04 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <14444.1498745576.1@sss.pgh.pa.us> Date: Thu, 29 Jun 2017 10:12:56 -0400 Message-ID: <14445.1498745576@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Merlin Moncure writes: > On Thu, Jun 29, 2017 at 8:23 AM, Michal Novotny > 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