pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
To: Michael Paquier <michael.paquier@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-odbc@postgresql.org>
Subject: Re: CC_send_query_append crash
Date: Thu, 01 May 2014 13:47:36 +0200
Message-ID: <1398944856.4578.51.camel@watchmen.homenetwork> (raw)
In-Reply-To: <CAB7nPqTCD9jtjY3F2i-HXR5PZu8GyUQvesUaJLMZOYsSoQ0z=A@mail.gmail.com>
References: <1398789887.4578.19.camel@watchmen.homenetwork>
	<CAB7nPqTCD9jtjY3F2i-HXR5PZu8GyUQvesUaJLMZOYsSoQ0z=A@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-odbc>


> <malcolm.macleod@tshwanedje.com> 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



view thread (7+ messages)  latest in thread

Message-ID: <1398944856.4578.51.camel@watchmen.homenetwork>
Permalink:  ../1398944856.4578.51.camel@watchmen.homenetwork/
Also on:    postgresql.org/message-id/1398944856.4578.51.camel@watchmen.homenetwork

 · 

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-odbc@postgresql.org
  Cc: malcolm.macleod@tshwanedje.com, michael.paquier@gmail.com
  Subject: Re: CC_send_query_append crash
  In-Reply-To: <1398944856.4578.51.camel@watchmen.homenetwork>
  References: <1398789887.4578.19.camel@watchmen.homenetwork> <CAB7nPqTCD9jtjY3F2i-HXR5PZu8GyUQvesUaJLMZOYsSoQ0z=A@mail.gmail.com> <1398944856.4578.51.camel@watchmen.homenetwork>

* 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