After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 370081 - DBus Exception on Solaris
DBus Exception on Solaris
Status: RESOLVED OBSOLETE
Product: f-spot
Classification: Other
Component: General
CVS
Other Solaris
: Normal normal
: 0.7.0
Assigned To: F-spot maintainers
F-spot maintainers
Depends on:
Blocks:
 
 
Reported: 2006-11-03 16:06 UTC by Stephane Delcroix
Modified: 2010-06-08 09:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to mono/support (1.12 KB, patch)
2006-11-06 20:26 UTC, Jonathan Pryor
none Details | Review
Makes dbus-sharp work on Solaris (1.32 KB, patch)
2006-11-07 14:17 UTC, Mark Phalan
none Details | Review

Description Stephane Delcroix 2006-11-03 16:06:38 UTC
As reported on the mailing-list:

I'm trying to run f-spot on Solaris x86 (Nevada). 

I get the following:

$ f-spot
GC Warning: Large stack limit(10485760): only scanning 8 MB

Unhandled Exception: System.EntryPointNotFoundException: socket
in (wrapper managed-to-native) NDesk.DBus.Transports.UnixSocket:socket (int,int,int)
in <0x00010> NDesk.DBus.Transports.UnixSocket:.ctor ()
in <0x0011a> NDesk.DBus.Transports.UnixNativeTransport:OpenUnix (System.String path)
in <0x00054> NDesk.DBus.Transports.UnixNativeTransport:.ctor (System.String path, Boolean abstract)
in <0x0002a> NDesk.DBus.Connection:Open (System.String path, Boolean abstr)
in <0x00053> NDesk.DBus.Connection:OpenPrivate (System.String address)
in <0x00087> NDesk.DBus.Connection:.ctor (System.String address)
in <0x00011> NDesk.DBus.Bus:.ctor (System.String address)
in <0x00059> NDesk.DBus.Bus:Open (System.String address)
in <0x00019> NDesk.DBus.Bus:get_System ()
in <0x0001a> NDesk.DBus.BusG:Init ()
in <0x000af> FSpot.Driver:Main (System.String[] args)
$

mono 1.1.13.8.1
gtk-sharp 2.8.2
f-spot is 0.2.2.
gnome is 2.16.1

Everything was compiled with gcc 3.4.3.

dbus is running and appears to be working fine.

I'm not sure how to debug this as I have no experience with mono or c#. Any help would be appreciated.

I get the exact same back trace when I try to run the latest banshee.

Thanks,

-Mark
Comment 1 Stephane Delcroix 2006-11-03 16:14:14 UTC
Mark,

can you give the result of those commands:

export | grep DBUS

and

ls -l /var/run/dbus/system_bus_socket

Comment 2 Mark Phalan 2006-11-03 16:22:31 UTC
phalan:~$ export | grep DBUS
DBUS_SESSION_BUS_ADDRESS='unix:path=/tmp/dbus-FNugDpzuAp,guid=e6254b4552a94f26aed7926444442e00'
phalan:~$ ls -l /var/run/dbus/system_bus_socket
srwxrwxrwx 1 root root 0 Nov  3 14:38 /var/run/dbus/system_bus_socket=
phalan:~$ 
Comment 3 Mark Phalan 2006-11-03 19:04:55 UTC
Ok I think I know what the problem is.

On Solaris socket(), connect(), bind() and listen() are delivered in libsocket and not libc.
If you write code with these funcs you need to link against libsocket and libnsl.
The suspect code is in dbus-sharp/UnixNativeTransport.cs.
I've tried replacing libc with libsocket but it still doesn't work (see stack trace below).

I'm not familiar with how DllImport works so I'm probably messing this up somehow. How can I let dbus-sharp know that it needs to use libsocket and libnsl?


GC Warning: Large stack limit(10485760): only scanning 8 MB

Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for Mono.Unix.Native.Stdlib ---> System.DllNotFoundException: libMonoPosixHelper.so
in (wrapper managed-to-native) Mono.Unix.Native.Stdlib:GetDefaultSignal ()
in <0x0000f> Mono.Unix.Native.Stdlib:.cctor ()--- End of inner exception stack trace ---

in <0x00000> <unknown method>
in <0x0000b> Mono.Unix.UnixMarshal:CreateExceptionForLastError ()
in <0x0000a> Mono.Unix.UnixMarshal:ThrowExceptionForLastError ()
in <0x0000d> Mono.Unix.UnixMarshal:ThrowExceptionForLastErrorIf (Int32 retval)
in <0x00025> NDesk.DBus.Transports.UnixSocket:Connect (System.Byte[] remote_end)
in <0x0012c> NDesk.DBus.Transports.UnixNativeTransport:OpenUnix (System.String path)
in <0x00054> NDesk.DBus.Transports.UnixNativeTransport:.ctor (System.String path, Boolean abstract)
in <0x0002a> NDesk.DBus.Connection:Open (System.String path, Boolean abstr)
in <0x00053> NDesk.DBus.Connection:OpenPrivate (System.String address)
in <0x00087> NDesk.DBus.Connection:.ctor (System.String address)
in <0x00011> NDesk.DBus.Bus:.ctor (System.String address)
in <0x00059> NDesk.DBus.Bus:Open (System.String address)
in <0x00019> NDesk.DBus.Bus:get_System ()
in <0x0001a> NDesk.DBus.BusG:Init ()
in <0x000af> FSpot.Driver:Main (System.String[] args)
Comment 4 Stephane Delcroix 2006-11-04 14:29:46 UTC
As you did, replacing libc by the right lib in UnixNativeTransport should tell that class where to look for the methods.

Do you have a libMonoPosixHelper.so installed somewhere ?
Comment 5 Stephane Delcroix 2006-11-04 16:06:43 UTC
You can probably also leave the code as-is and try to provide a NDesk.DBus.dll.config (next to the installed NDesk.DBus.dll) remapping some functions to other libs.

This file should look like

<configuration>
        <dllmap dll="libc">
            <dllentry os="solaris" dll="libsocket.so" name="connect" />
        </dllmap>
</configuration>

According to this: http://www.mono-project.com/Config_DllMap you need mono 1.1.18 to use that configuration.

Try it, and report what's working and what's not
Comment 6 Mark Phalan 2006-11-04 17:59:07 UTC
Ok I couldn't get the NDesk.Dbus.dll.config file to make any difference so I simply modified UnixNativeTransport.cs to use libsocket instead of libc.

I'm now getting the following:

Unhandled Exception: Mono.Unix.UnixIOException: Protocol wrong type for socket [EPROTOTYPE].
  at Mono.Unix.UnixMarshal.ThrowExceptionForLastError () [0x00000] 
  at Mono.Unix.UnixMarshal.ThrowExceptionForLastErrorIf (Int32 retval) [0x00000] 
  at NDesk.DBus.Transports.UnixSocket.Connect (System.Byte[] remote_end) [0x00000] 
  at NDesk.DBus.Transports.UnixNativeTransport.OpenUnix (System.String path) [0x00000] 
  at NDesk.DBus.Transports.UnixNativeTransport..ctor (System.String path, Boolean abstract) [0x00000] 
  at NDesk.DBus.Connection.Open (System.String path, Boolean abstr) [0x00000] 
  at NDesk.DBus.Connection.OpenPrivate (System.String address) [0x00000] 
  at NDesk.DBus.Connection..ctor (System.String address) [0x00000] 
  at NDesk.DBus.Bus..ctor (System.String address) [0x00000] 
  at NDesk.DBus.Bus.Open (System.String address) [0x00000] 
  at NDesk.DBus.Bus.get_System () [0x00000] 
  at NDesk.DBus.BusG.Init () [0x00000] 
  at FSpot.Driver.Main (System.String[] args) [0x00000] 


socket(3m) returns EPROTOTYPE when:

The file that is referred to by name
is  a  socket  of  a type other than
type  s.  For  example,   s   is   a
SOCK_DGRAM socket, while name refers
to a SOCK_STREAM socket.

Comment 7 Mark Phalan 2006-11-04 21:23:54 UTC
Ok well using truss I discovered that the socket was being created as a datagram socket... the bug being that SocketType.Stream resolved to SOCK_DGRAM. I'm not sure why this happened (still investigating). By hardcoding the stream type as an integer I got a little farther:

Unhandled Exception: System.ArgumentOutOfRangeException: Current platform doesn't support this value.
Parameter name: value
SEEK_CUR
in <0x0003d> Mono.Unix.Native.NativeConvert:ThrowArgumentException (System.Object value)
in <0x0003f> Mono.Unix.Native.NativeConvert:FromSeekFlags (SeekFlags value)
in <0x0000f> Mono.Unix.Native.Syscall:lseek (Int32 fd, Int64 offset, SeekFlags whence)
in <0x0006f> Mono.Unix.UnixStream:.ctor (Int32 fileDescriptor, Boolean ownsHandle)
in <0x0000f> Mono.Unix.UnixStream:.ctor (Int32 fileDescriptor)
in (wrapper remoting-invoke-with-check) Mono.Unix.UnixStream:.ctor (int)
in <0x000a0> NDesk.DBus.Transports.UnixNativeTransport:.ctor (System.String path, Boolean abstract)
in <0x0002a> NDesk.DBus.Connection:Open (System.String path, Boolean abstr)
in <0x00053> NDesk.DBus.Connection:OpenPrivate (System.String address)
in <0x00087> NDesk.DBus.Connection:.ctor (System.String address)
in <0x00011> NDesk.DBus.Bus:.ctor (System.String address)
in <0x00059> NDesk.DBus.Bus:Open (System.String address)
in <0x00019> NDesk.DBus.Bus:get_System ()
in <0x0001a> NDesk.DBus.BusG:Init ()
in <0x000af> FSpot.Driver:Main (System.String[] args)


However I'm beginning to think that I may have larger problems... 
Comment 8 Jonathan Pryor 2006-11-06 20:26:02 UTC
Created attachment 76109 [details] [review]
Patch to mono/support

Please apply the attached patch to your mono/support directory, rebuild mono/support, and `make install' within mono/support (to install the updated MonoPosixHelper library).

The problem is that mono/support/map.c:Mono_Posix_FromSeekFlags tries to find the platform-specific value of e.g. SeekFlags.SEEK_SET.  However, SeekFlags contains aliases -- SEEK_SET is aliased by L_SET -- and the alias is "searched" first.  Since Solaris doesn't have a BSD userland, it doesn't have L_SET, L_INCR, or L_XTND, so the mapping will *always* fail.

The attached patch simply ensures that the macros L_SET, L_INCR, and L_XTND always exist.
Comment 9 Mark Phalan 2006-11-07 14:15:47 UTC
Its now working (and so is Banshee)!

To summarize the changes I had to make:

1. Modify dbus-sharp/UnixNativeTransport.cs replacing 'libc' with 'libsocket' as connect(3), bind(3), socket(3) and listen(3) are delivered with libsocket on Solaris.

2. Modify dbus-sharp/UnixNativeTransport.cs to use '2' as a hardcoded value instead of SocketType.Stream in the call to socket().


3. Modify mono/map.c to define L_SET, L_INCR and L_XTND (see above for patch).

I've attached a diff for the first two. 
Comment 10 Mark Phalan 2006-11-07 14:17:46 UTC
Created attachment 76153 [details] [review]
Makes dbus-sharp work on Solaris
Comment 11 Stephane Delcroix 2006-11-07 21:56:05 UTC
Mark, really happy that it's working for you now !!!

Jonathan, do you have a bug entry in mono to follow this patch yet ? or is it in svn yet ?
Comment 12 Jonathan Pryor 2006-11-07 23:28:55 UTC
The mono/support fix has been committed to mono svn.

Note that this fix is *not* currently part of the Mono 1.2 Release Candidates, and I don't know if it will be part of the final 1.2 release.
Comment 13 Jonathan Pryor 2006-11-09 19:28:26 UTC
The mono/support fix is *not* part of the final Mono 1.2 release.  You will need to wait for a later Mono 1.2.x release for proper Solaris support.
Comment 14 alp 2006-11-11 16:28:31 UTC
As an alternative, it should be possible to build managed D-Bus with UnixMonoTransport.cs instead of UnixNativeTransport.cs with a recent versions of Mono installed. This is likely to work since the correct constant value is compiled into Mono.Unix.

I still have to devise a way to fix this portably, but Solaris packagers are welcome to patch the library with either Mark's fix or mine as a temporary measure until there's a new release with a proper solution.
Comment 15 Ruben Vermeersch 2010-05-25 13:43:09 UTC
We are no longer bundling ndesk-dbus, so this should really go upstream, if still needed.