Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dRzMQ-0001H6-M8 for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Jul 2017 11:17:46 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dRzMQ-0006AD-8u for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Jul 2017 11:17:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dRvu9-0005wo-M0 for pgsql-hackers@postgresql.org; Mon, 03 Jul 2017 07:36:21 +0000 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dRvu6-000250-Ev for pgsql-hackers@postgresql.org; Mon, 03 Jul 2017 07:36:21 +0000 Received: by mail-wm0-x233.google.com with SMTP id w126so159323851wme.0 for ; Mon, 03 Jul 2017 00:36:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=greycortex-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=vDL3MZMW9tjnFMpsTKbPbYMzRl+eVLS8jurHy+UJ5zM=; b=yXCjDc29+qoro/oaiifrKLfunAD23nV+/To2YL+Ga6tZK3gCytnXB3caCj/Cmw94nb xBZk4iR5ces3FStg5Sqb2AqQZmAQUmTYIKREdGRWfJk3Me03jdOhaWKeex5FwmSKHo4W ZwyzT6dN6Fq4wcM6SBWsTjjKlcXcsb3Fg6ADD57bryTy8xRnDol71Ryll7IR8OPeEFn/ 1OOR1gjcXSGCpIwVCoIyCi3C9LLBvSGFwX9L2gGnhoI+963uHPehos1XJhGpO3DSZofX xOa6h3L0WmthafBfCJ/7IHnOw0gEAocxKYzJmp5WWyGYlTgje7ES3CzPlO7cFS3TlIIF CCpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=vDL3MZMW9tjnFMpsTKbPbYMzRl+eVLS8jurHy+UJ5zM=; b=L2oAEQYQ8GXkocEftOMQq22XhIoRGhOEHkJranDYdOuTlh4BvFbouW54ykvhpudfbR 63bG2F6AzuNBA/qaMB6YivOn46Mk4zm04h1zV/Dixl4nj5Nll9bCU/62gf7fRjQ/NXb+ oV13gZAeni/XQ/TEV9xuB3Y7Kmebj9I0YP7zrecKEdLHuxzr4IR35L5IfKWlb96PKIQL fg6snFc/OtF/PlxBFGaDFZo1WpRRivmVMZiCdPMyaWXBzxpy454r/taf/EEMYvEP+7/V z2Dl7I+DOs0KeM5Ejy8GALyGkIBdjJ7GJk5ECkSzZsO5gF0GnZu6jkEa6L1Zb0htsHC2 5B/Q== X-Gm-Message-State: AIVw112JjhR5xb+/jdxB8GvQN4Z+61TsnrCUW6quiUzO8YtJaMe0DPCB X0qf7R9xA68gg/wMLMSHnw== X-Received: by 10.28.71.133 with SMTP id m5mr2844189wmi.97.1499067376407; Mon, 03 Jul 2017 00:36:16 -0700 (PDT) Received: from [172.16.9.180] ([195.113.243.75]) by smtp.gmail.com with ESMTPSA id w96sm11828265wrc.33.2017.07.03.00.36.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jul 2017 00:36:15 -0700 (PDT) Subject: Re: [BUGS] Segmentation fault in libpq To: Craig Ringer , Andres Freund Cc: Merlin Moncure , Tom Lane , pgsql-bugs , PostgreSQL-development References: <2a0f743f-4d96-30b1-8b5d-86541e8bcb34@greycortex.com> <14445.1498745576@sss.pgh.pa.us> <20170702191222.uk4hokc2iumzeenh@alap3.anarazel.de> From: Michal Novotny Message-ID: Date: Mon, 3 Jul 2017 09:36:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-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 On 07/03/2017 04:58 AM, Craig Ringer wrote: > On 3 July 2017 at 03:12, Andres Freund wrote: >> Hi, >> >> On 2017-07-02 20:58:52 +0200, Michal Novotný wrote: >>> thank you all for your advice. I've been investigating this a little more >>> and finally it turned out it's not a bug in libpq although I got confused >>> by going deep as several libpq functions. The bug was really on our side >>> after trying to use connection pointer after calling PQfinish(). The code >>> is pretty complex so it took some time to investigate however I would like >>> to apologize for "blaming" libpq instead of our code. >> Usually using a tool like valgrind is quite helpful to find issues like >> that, because it'll show you the call-stack accessing the memory and >> *also* the call-stack that lead to the memory being freed. > Yep, huge help. > > BTW, on Windows, the free tool DrMemory (now 64-bit too, yay) or > commercial Purify work great. Well, good to know about Windows stuff however we use Linux so that's not a big deal. Unfortunately it's easy to miss something in valgrind if you have once multi-threaded library linked to libpq and this multi-threaded library is used in conjunction with another libraries sharing some of the data among them. Thanks once again, Michal -- Michal Novotny System Development Lead michal.novotny@greycortex.com GREYCORTEX s.r.o. Purkynova 127, 61200 Brno Czech Republic www.greycortex.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers