Weird behaviour with the Vala Skype status client sample



Hi all,

I'm sending this to both vala-list and gtk-list as this is a Vala
sample but the problem is caused by weird behaviour in gio.

I've tested this with glib and vala on Fedora 17, Ubuntu 12.04 and
with git master of both of them.

I was trying the Skype status client sample from
https://live.gnome.org/Vala/DBusClientSamples .

Despite the source looking fine, executing the program only resulted
in a Segmentation Fault.

As it turned out the problem was this function:

string send (Skype skype, string cmd) throws IOError {
    return skype.invoke (cmd);
}

Simply renaming this function solves the problem. To find out what is
causing the problem I generated the c file once with send as function
name and once with send2. However after using diff to compare the
files the only thing that had changed was that the c name of the
function now too was send2. (as expected). So the vala compiler seems
to do the right thing.

In the error case the compiler produces the function as
gchar* send (Skype* skype, const gchar* cmd, GError** error);

Checking the backtrace with gdb finally revealed what was going on.
The segfault already occurs within g_initable_new of the Skype proxy
object which seems to be responsible for the initialization of dbus
connection. Anyway the real problem occurs within GSocket.

g_socket_send_with_blocking (socket=0x6135e0, buffer=0x7ffff7db622c
"AUTH\r\n", size=6, blocking=1, cancellable=0x0, error=0x6180a8) at
gsocket.c:2665

This is line 2665 of gsocket.c in git master:

if ((ret = send (socket->priv->fd, buffer, size,
G_SOCKET_DEFAULT_SEND_FLAGS)) < 0)

This is obviously supposed to call the posix send function. However it
calls the function from the skype client program which in return calls
skype_invoke.

Since the file descriptor of the socket is passed as the Skype object
this obviously segfaults:
return SKYPE_GET_INTERFACE (self)->invoke (self, cmd, error);

Now my question is why does this happen ? Can an application
"override" a function in a library it's using and if so shouldn't
there be a compiler warning?

Thanks in advance,
Tom Alan


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]