Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WgIWz-0004jb-Gt for pgsql-odbc@arkaria.postgresql.org; Fri, 02 May 2014 18:49:57 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WgIWy-0007gm-Nf for pgsql-odbc@arkaria.postgresql.org; Fri, 02 May 2014 18:49:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WfpSs-0002jg-Ps for pgsql-odbc@postgresql.org; Thu, 01 May 2014 11:47:47 +0000 Received: from mail-ee0-x232.google.com ([2a00:1450:4013:c00::232]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WfpSp-0004pp-DG for pgsql-odbc@postgresql.org; Thu, 01 May 2014 11:47:46 +0000 Received: by mail-ee0-f50.google.com with SMTP id c13so2226489eek.9 for ; Thu, 01 May 2014 04:47:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:subject:from:reply-to:to:cc:date:in-reply-to :references:organization:content-type:mime-version :content-transfer-encoding; bh=pvzH22lSMfhdIEp0hwGmILGJ0CBXF2S2yCOsZk7FFxY=; b=wI5XdE0OZ8GmUtkRZIZ9+17O1yRRZ7EcxCC1J6EyDWV3+tJR+uGbArWrT2RhUoyqNl A+pDN+cYVzNGzPsujn4pgCm0rLfTk2DsPW1T2UbS8rxUKvB6DFZIQB3dSuTsAuuvm079 tDTcFSlnxhRha/+FuGWs0cLZxqWVhMFtxftHk8qp9l2Gg4b1hvBC9qqA/4Ev0OxFurFh mZNzJGYiJs8BCUQf/IbsN6PR37edG73nhTzaT+65mTwuTKPQUedtF8PydRpaxlG3IlYx CHKRz7acLwREvBGZ0pbgXtMbSAj7iA6ROj2Q6jhDOKxHaDUVZG24UiW9uZ3lWNIxZooV qBmQ== X-Received: by 10.14.95.8 with SMTP id o8mr9461140eef.15.1398944862743; Thu, 01 May 2014 04:47:42 -0700 (PDT) Received: from [10.0.0.24] (105-236-223-62.access.mtnbusiness.co.za. [105.236.223.62]) by mx.google.com with ESMTPSA id t44sm75741828eeo.6.2014.05.01.04.47.40 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 01 May 2014 04:47:41 -0700 (PDT) Message-ID: <1398944856.4578.51.camel@watchmen.homenetwork> Subject: Re: CC_send_query_append crash From: Malcolm MacLeod Reply-To: malcolm.macleod@tshwanedje.com To: Michael Paquier Cc: PostgreSQL mailing lists Date: Thu, 01 May 2014 13:47:36 +0200 In-Reply-To: References: <1398789887.4578.19.camel@watchmen.homenetwork> Organization: TshwaneDJe HLT Content-Type: text/plain; charset="us-ascii" X-Mailer: Evolution 3.8.5 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-odbc Precedence: bulk Sender: pgsql-odbc-owner@postgresql.org > wrote: > > The crash seems to occur because CC_send_query_append crash takes a > > local copy of the pointer 'self->sock' at the top of the function, > > 'self' is then passed around to various functions (some of which have > > the side effect of setting self->sock to NULL (and deleting) if there is > > a lost connection) and then the local copy of the pointer (which is now > > dangling) is dereferenced lower down in the function. > > Essentially if there is a disconnect while CC_send_query_append is > > running there is a risk of crash. > Looking at the code, I am seeing that the problem is related to > CC_on_abort where conn->sock is set to NULL when the connection is > considered as dead. And I am indeed seeing two code paths (when > sending the 'C' message there is an ABORT check and in cleanup > section) that could use this NULL socket afterwards. Your patch is > perhaps a bit too much. So I am proposing the attached patch instead. > Let me know if this fixes your issue as well. Thanks for the fast response! Your proposed patch would also fix the issue, so I have no problem with it being used instead. I guess from my side I just don't personally understand the point of keeping the local pointer copy at all (it just seems like an invitation for this sort of thing to occur) - so it made more sense to me to remove it entirely to prevent future occurrences of similar issues - although I suppose also the less code disturbed the better. I am not overly familiar with the code so can't say what is best. Thanks, Malcolm -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc