Bug 56598 - DBus-sharp hangs until next dbus request.
Summary: DBus-sharp hangs until next dbus request.
Status: RESOLVED ANSWERED
Alias: None
Product: Runtime
Classification: Mono
Component: Reflection ()
Version: 5.0 (2017-02)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Aleksey Kliger
URL:
Depends on:
Blocks:
 
Reported: 2017-05-18 07:38 UTC by Mikkel Kruse Johnsen
Modified: 2017-07-07 20:06 UTC (History)
4 users (show)

Tags: No_Shiproom
Is this bug a regression?: Yes
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Mikkel Kruse Johnsen 2017-05-18 07:38:21 UTC
When using Mono 5.0.0.100 with DBus-sharp on Windows. DBus signal hangs until next DBus signal i requested.

It works fine on Mono 4.8 and before.

I use exact same dbus-daemon.exe and DBus-sharp. It is only Mono that has changed in the setup.

I don't really have much to go on I will update when I find more.
Comment 1 Mikkel Kruse Johnsen 2017-05-18 10:08:08 UTC
I see this on Mono 5.0.0.100 on windows: (Works fine with Mono 4.8 and less):

Type:	 System.ArgumentException
Message: Duplicate type name within an assembly.

  at System.Reflection.Emit.ModuleBuilder.DefineType (System.String name, System.Reflection.TypeAttributes attr, System.Type parent, System.Type[] interfaces, System.Reflection.Emit.PackingSize packingSize, System.Int32 typesize) [0x00053] in /home/mkj/Projects/AppBox/rpm/BUILD/mono-5.0.0/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs:275 
  at System.Reflection.Emit.ModuleBuilder.DefineType (System.String name, System.Reflection.TypeAttributes attr, System.Type parent, System.Type[] interfaces) [0x00000] in /home/mkj/Projects/AppBox/rpm/BUILD/mono-5.0.0/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs:292 
  at System.Reflection.Emit.ModuleBuilder.DefineType (System.String name, System.Reflection.TypeAttributes attr, System.Type parent) [0x00000] in /home/mkj/Projects/AppBox/rpm/BUILD/mono-5.0.0/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs:246 
  at DBus.TypeImplementer.GetImplementation (System.Type declType) [0x0006b] in <1eb41289591d4a0ba6dbf0ab492738da>:0 
  at DBus.BusObject.GetObject (DBus.Connection conn, System.String bus_name, DBus.ObjectPath object_path, System.Type declType) [0x00001] in <1eb41289591d4a0ba6dbf0ab492738da>:0 
  at DBus.Connection.GetObject (System.Type type, System.String bus_name, DBus.ObjectPath path) [0x0002b] in <1eb41289591d4a0ba6dbf0ab492738da>:0 
  at DBus.Connection.GetObject[T] (System.String bus_name, DBus.ObjectPath path) [0x00001] in <1eb41289591d4a0ba6dbf0ab492738da>:0 
  at OpenMedicus.SecurityBusService.GetSecurityBus () [0x00007] in /home/mkj/Projects/XMedicus/libxcaresecuritybus/SecurityBusService.cs:47 
  at OpenMedicus.Home.DisplayStream (System.IO.TextReader stream) [0x0001f] in /home/mkj/Projects/XMedicus/libxcaresettings/Home.cs:37 
  at OpenMedicus.Setting..ctor (Gtk.Builder builder, System.String name) [0x0005e] in /home/mkj/Projects/XMedicus/libxcaresettings/Settings.cs:45 
  at OpenMedicus.Setting..ctor (OpenMedicus.IConnectionManager cm) [0x00000] in /home/mkj/Projects/XMedicus/libxcaresettings/Settings.cs:53 
  at OpenMedicus.Shell.ShowSettings () [0x00012] in /home/mkj/Projects/XMedicus/libxcareshell/Shell.cs:1793 
  at OpenMedicus.Shell.OnEditPreferencesCallback (System.Object obj, System.EventArgs a) [0x0000f] in /home/mkj/Projects/XMedicus/libxcareshell/Shell.cs:3627
Comment 2 Aleksey Kliger 2017-05-23 16:34:42 UTC
Mikkel,

It would be helpful to know the Type:FullName of the type T that's being passed to DBus.Connection.GetObject<T>(...).

Also are you interacting with DBus from multiple threads? It seems like this could happen if two threads both call ModuleBuilder.DefineType.

(Ideally of course if you could provide a small self-contained example that reproduces the problem that would be fantastic).
Comment 3 Mikkel Kruse Johnsen 2017-05-24 11:31:33 UTC
The Fullname should be used, please see

https://github.com/openmedicus/dbus-sharp/blob/master/src/TypeImplementer.cs:59

Should be the latest DBus-sharp source code I use.

I don't Request from different threads. I only use async/await, so there should be no threads.

It works fine with Mono 4.8.
Comment 4 Ludovic Henry 2017-07-07 19:34:29 UTC
Aleksey, do you have enough info to reproduce?
Comment 5 Aleksey Kliger 2017-07-07 20:06:51 UTC
Mikkel,

Using async means that multiple tasks could potentially try to interact with System.Reflection.Emit at the same type which could lead to the error that you see.

This looks like incorrect locking in dbus-sharp.  Please report it at https://github.com/mono/dbus-sharp/issues

Looking at TypeImplementer.cs:59 it looks like multiple tasks that call TypeImplementer:GetImplementation will both try to call DefineType with the same name.  (They'll synchronize on getImplLock on line 55, but then both will get NULL from the map and continue to line 59.   getImplLock is only protecting concurrent access to the map variable, not to ModuleBuilder.DefineType).

Thanks,
Aleksey