Hi Wander Nauta,

As per comment above the mutex lock, we need to hold the lock until, the
context menu is getting popped up correctly.
I've modified the code accordingly.

Can you please test the attached patch?

--

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>

On Mon, Apr 20, 2015 at 1:21 PM, Dave Page <dp...@pgadmin.org> wrote:

> Ashesh; can you look at this please?
>
> Thanks.
>
> On Sun, Apr 19, 2015 at 3:44 PM, Wander Nauta <i...@wandernauta.nl> wrote:
> > Hello all,
> >
> > I did some more digging and it seems frmMain::OnSelRightClick is
> > trying to unlock a mutex it doesn't own, which can result in undefined
> > behaviour in POSIX.
> >
> > I've attached a patch that moves the unlock inside the if where the
> > mutex is locked. This seems to fix the crash, at least on my end, but
> > I couldn't say if it affects thread safety at all.
> >
> > Again, I hope this helps.
> >
> > Kind regards,
> > Wander Nauta
> >
> >
> > --
> > Sent via pgadmin-support mailing list (pgadmin-support@postgresql.org)
> > To make changes to your subscription:
> > http://www.postgresql.org/mailpref/pgadmin-support
> >
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/pgadmin/frm/events.cpp b/pgadmin/frm/events.cpp
index 556fc73..0e910bb 100644
--- a/pgadmin/frm/events.cpp
+++ b/pgadmin/frm/events.cpp
@@ -738,16 +738,17 @@ void frmMain::OnSelRightClick(wxTreeEvent &event)
 	if (item != browser->GetSelection())
 	{
 		browser->SelectItem(item);
+    }
 
-		// Prevent changes to "currentObject" by "execSelchange" function by another thread.
-		// Will hold the lock until we do popup on the respective object.
-		//
-		s_currentObjectMutex.Lock();
-		currentObject = browser->GetObject(item);
-	}
+	// Prevent changes to "currentObject" by "execSelchange" function by another thread.
+	// Will hold the lock until we do popup on the respective object.
+	//
+	s_currentObjectMutex.Lock();
+	currentObject = browser->GetObject(item);
 
 	if (currentObject)
 		doPopup(browser, event.GetPoint(), currentObject);
+
 	s_currentObjectMutex.Unlock();
 }
 
-- 
Sent via pgadmin-support mailing list (pgadmin-support@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-support

Reply via email to