-
Notifications
You must be signed in to change notification settings - Fork 6
telepathy-idle 0.2 unit test fixes #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
telepathy-idle 0.2 unit test fixes #3
Conversation
Valid for 10 years
Because stream.nick is Unicode when sendMessage combines the command, nick, and invalid utf8 python 2.7 ends up converting everything to Unicode. Since this test deliberately includes invalid Unicode, Python notices and throws an exception. In Python 3, network traffic is usually encoded as bytes. So I thought coercing the nick to bytes would be appropriate, and as bytes can contain anything including invalid Unicode, Python doesn't throw an exception.
| @@ -33,7 +33,7 @@ def test(q, bus, conn, stream): | |||
| q.expect_many( | |||
| EventPattern('dbus-signal', signal='StatusChanged', args=[2, 1]), | |||
| EventPattern('irc-disconnected'), | |||
| EventPattern('dbus-return', method='Disconnect')) | |||
| EventPattern('dbus-error', method='Disconnect')) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks suspicious. I wouldn't change it so fast just to make the unit test work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Impatience is the route to poor misunderstood fixes.
So I did find this error in the dbus logs
h=/org/freedesktop/Telepathy/Connection/idle/irc/test_40127_2e0_2e0_2e10x558a89c
9d200; interface=org.freedesktop.Telepathy.Connection; member=Disconnect
error time=1509901413.759072 sender=org.freedesktop.DBus -> destination=:1.1 error_name=org.freedesktop.DBus.Error.ServiceUnknown reply_serial=16
string "The name :1.2 was not provided by any .service files"
And
telepathy-idle[28715] trap int3 ip:7f567fb2a911 sp:7ffd78300f90 error:0 in libglib-2.0.so.0.5400.1[7f567fada000+111000]```
In my dmesg logs. so that is suggestive of something crashing
Though I'm not sure how to get telepathy-idle into a debugger as the printed pid is for the test dbus session
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dug further. from src/idle-connection.c around line 800
static void sconn_disconnected_cb(IdleServerConnection *sconn, IdleServerConnectionStateReason reason, IdleConnection *conn) {
IdleConnectionPrivate *priv = conn->priv;
TpConnectionStatusReason tp_reason;
/* cancel scheduled forced disconnect since we are now disconnected */
if (priv->force_disconnect_id) {
g_source_remove(priv->force_disconnect_id);
priv->force_disconnect_id = 0;
}The crash is when g_source_remove() is called.
The documentation for g_source_remove says "It is a programmer error to attempt to remove a non-existent source."
If I comment out the g_source_remove it doesn't crash for this test (and the test gets a dbus-return, method="Disconnect".)
But I'm having trouble figuring out how to tell if the g_source_remove call is unneeded.
Several obvious functions like g_source_is_destroyed or g_main_context_find_source_by_id all say its illegal to call if the GSource is non-existent.
The force_timeout_id is created in line 624 with the call
/* schedule forceful disconnect for 2 seconds if the remote server doesn't
* respond or disconnect before then */
priv->force_disconnect_id = g_timeout_add_seconds(2, _force_disconnect, conn);The docs say that the timeout is automatically destroyed when it returns FALSE.
What about setting force_disconnect_id to 0 in _force_disconnect?
@@ -600,6 +600,7 @@ _force_disconnect (gpointer data)
IDLE_DEBUG("gave up waiting, forcibly disconnecting");
idle_server_connection_force_disconnect(priv->conn);
+ priv->force_disconnect_id = 0;
return FALSE;
}
That avoids any crashes and the all the tests pass with and the ones I changed, changed back to dbus-return, method="Disconnect".
There may be a resource leak but I'm not sure how to check?
…royed I asked one of the polari devs and was told that yes it is ok to set the timer id to zero in the timer function. With this patch make check works without changing any of the expected test results and without any coredumps
4a26b66 to
acf5fcf
Compare
|
Ok I force pushed a new, probably more correct fix. The docs say the timer function is cleaned up after returning FALSE, and if I explained it correctly that means the GSource has already been destroyed. so I set the force_disconnect_id to 0 to indicate its already been cleaned up. |
|
Looks good to me. Now the only part that I don't get is why the "ctcp: ... " commit appears again in this PR? It is already committed both in master and the 0.2 branch. |
|
@detrout ping? |
This is because we messed up the target branch. If I got this right, It should be |
While trying to prepare a release I ran make check and a few things didn't work.
These solutions work, though there might be some better alternatives. See the commit messages for more details