Bug 5716 - under some conditions getSessionBus returns null
Summary: under some conditions getSessionBus returns null
Status: RESOLVED WONTFIX
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: high normal
Assignee: Joe Shaw
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-25 10:02 UTC by Christian Krause
Modified: 2006-08-01 10:27 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Christian Krause 2006-01-25 10:02:42 UTC
recently I filed this bug for banshee:
http://bugzilla.gnome.org/show_bug.cgi?id=327595
This one was closed with a comment that there could be a problem with dbus and mono.

I've done some debugging and it seems, that this could be true ;-)

in dbus-0.60/mono/Connection.cs:
    internal static Connection Wrap(IntPtr rawConnection) 
    {
      if (slot > -1) {
	// Maybe we already have a Connection object associated with
	// this rawConnection then return it
	IntPtr rawThis = dbus_connection_get_data (rawConnection, slot);
	if (rawThis != IntPtr.Zero) {
	  return (DBus.Connection) ((GCHandle)rawThis).Target;
	}
      }
      

It seems, that as long dbus_connection_get_data returns a value != NULL, it is
assumed that there is still a Target associated to the GCHandle object.

But the GCHandle's Target is associated as Weak target:
	      rawThis = GCHandle.Alloc (this, GCHandleType.WeakTrackResurrection);

I'm not very familiar with mono, but as far as I read this means, that it is
possible that the Target of the GCHandle can be freed by the garbage collector
(otherwise GCHanldeType.Normal should be used).

This means, that even if there is still a GCHandle, it is possible that the
target is already cleaned up. In this case, a null value is returned which
results later in an exception.

I've tested two possibilities to solve the problem:

1. associate the target as GCHandleType.Normal

2. only assume that there is already an DBus.Connection if the GCHandle's Target
has the type DBus.Connection:
...
	if (rawThis != IntPtr.Zero && ((GCHandle)rawThis).Target ==
typeof(DBus.Connection)) {
...

Both of them work.

It would be good if somebody could have a look at this issue.

Thank you very much!
Comment 1 John (J5) Palmieri 2006-02-11 08:28:26 UTC
joe, what is your take on this bug?
Comment 2 Christian Krause 2006-03-06 14:51:44 UTC
Hi,

Sorry for the bug spam, but please can anybody have a look to this bug?

Because it is more ore less a race condition the behaviour can be sometimes
strange and lead to even more strange bugs. It would be good, to solve this
problem in the near future to avoid other bugs with this problem as source...

Thank you very much in advance.
Comment 3 Christian Krause 2006-06-10 18:56:13 UTC
Hi,

I just want to ask if there are any news about this problem.
It seems, that in the meantime also other people suffer from this bug:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=187452

Please can a dbus-developer have a look at this problem? Please see my
description for a rough analysis of the cause of the problem.

Thank you very much in advance.


Btw, it is a little bit disappointing for contributers if they try to help and
not only report bugs but also try to solve them and even though the reports are
more or less ignored. :-( 


Comment 4 John (J5) Palmieri 2006-08-01 10:19:16 UTC
Closing bug.  The dbus-mono bindings have been unmaintained for a long time and
are no longer supported.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.