public inbox for [email protected]  
help / color / mirror / Atom feed
From: Ashesh Vashi <[email protected]>
To: Dave Page <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: [PATCH] pgAgent segfault
Date: Mon, 11 Jun 2018 09:55:06 +0530
Message-ID: <CAG7mmoy7ruK=HZGOt5GTFsuSF5e4+zHnagU0hJfuMUhqjZs=mw@mail.gmail.com> (raw)

Hi Dave,

While debugging the issue
<https://www.postgresql.org/message-id/CAG7mmoxXB0DsLZyvZ7qevoG17x7bJyw2DWdd0SXEgFg2Uc993A%40mail.gma...;
reported by Rob, I found one segfault.
Please find the attached patch to find that fix along with another one.

1. Connection object was being accessed, which was already released.

2. Changed the logic for checking the connection object existence.

We're using "if (!ms_primaryCon)", which should convert the logic as
boolean operator explicitly, which we defined for the 'DBconn' class.

I suspect some compilers (specifically windows one) may not behave that
way, and instead of using the boolean operator, it checks for the pointer
is NULL or not.

--

Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA: Enterprise PostgreSQL Company
<http://www.enterprisedb.com;


*http://www.linkedin.com/in/asheshvashi*
<http://www.linkedin.com/in/asheshvashi;


Attachments:

  [application/octet-stream] pgagent_segfault.patch (865B, 3-pgagent_segfault.patch)
  download | inline diff:
diff --git a/connection.cpp b/connection.cpp
index 15f6067..a961831 100644
--- a/connection.cpp
+++ b/connection.cpp
@@ -160,7 +160,7 @@ DBconn *DBconn::InitConnection(const std::wstring &connectString)
 			);
 	}
 
-	if (!ms_primaryConn)
+	if (ms_primaryConn->m_conn == NULL)
 	{
 		std::wstring error = ms_primaryConn->GetLastError();
 		delete ms_primaryConn;
diff --git a/pgAgent.cpp b/pgAgent.cpp
index 6928e4d..36b3835 100644
--- a/pgAgent.cpp
+++ b/pgAgent.cpp
@@ -207,7 +207,7 @@ void MainLoop()
 			MainRestartLoop(serviceConn);
 		}
 
-		LogMessage((boost::wformat(L"Couldn't create the primary connection (attempt %d): %s") % attemptCount % serviceConn->GetLastError()).str(), LOG_STARTUP);
+		LogMessage((boost::wformat(L"Couldn't create the primary connection [Attempt #%d]") % attemptCount).str(), LOG_STARTUP);
 
 		DBconn::ClearConnections(true);
 


view thread (2+ messages)  latest in thread

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: [PATCH] pgAgent segfault
  In-Reply-To: <CAG7mmoy7ruK=HZGOt5GTFsuSF5e4+zHnagU0hJfuMUhqjZs=mw@mail.gmail.com>

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

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