[Spice-commits] 3 commits - gtk/spice-channel.c gtk/spice-util.c
Christophe Fergau
teuf at kemper.freedesktop.org
Wed Oct 16 10:14:48 PDT 2013
gtk/spice-channel.c | 2 +-
gtk/spice-util.c | 41 ++++++++++++++++++++++++++++++-----------
2 files changed, 31 insertions(+), 12 deletions(-)
New commits:
commit 2cfcb59d87b914df4ad0dc9c53505d0229e90517
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Wed Oct 16 17:32:43 2013 +0200
sasl: Fix crash when ending a SASL session
When exiting remote-viewer after authenticating through SASL, I got
this crash:
#0 0x0000000100a51870 in ?? ()
#1 0x000000314d20c53e in _sasl_log (conn=<optimized out>, level=5, fmt=0x7fffe49893e8 "DIGEST-MD5 client mech dispose")
at common.c:1985
#2 0x00007fffe4982d88 in digestmd5_client_mech_dispose (conn_context=0xaf1900, utils=0xaefd10) at digestmd5.c:4580
#3 0x000000314d208654 in client_dispose (pconn=0xaf0710) at client.c:332
#4 0x000000314d20b76b in sasl_dispose (pconn=0xa51898) at common.c:851
#5 0x00007ffff7602dc7 in channel_reset (channel=0xa52250, migrating=0) at spice-channel.c:2493
#6 0x00007ffff760f7b7 in spice_inputs_channel_reset (channel=0xa52250, migrating=0) at channel-inputs.c:615
#7 0x00007ffff76030ac in spice_channel_reset (channel=0xa52250, migrating=0) at spice-channel.c:2551
#8 0x00007ffff76031e0 in channel_disconnect (channel=0xa52250) at spice-channel.c:2570
#9 0x00007ffff760283d in spice_channel_coroutine (data=0xa52250) at spice-channel.c:2368
#10 0x00007ffff763d14b in coroutine_trampoline (cc=0xa51900) at coroutine_ucontext.c:58
#11 0x00007ffff763ce30 in continuation_trampoline (i0=10819840, i1=0) at continuation.c:49
#12 0x00000031342479c0 in ?? () from /lib64/libc.so.6
#13 0x0000000000a51cc8 in ?? ()
#14 0x0000000000000000 in ?? ()
It turns out that the sasl_callback_t data passed when calling
sasl_client_new() must be valid until sasl_dispose() is called. I could not
find mentions of this in the official documentation but
https://mail-archives.apache.org/mod_mbox/subversion-dev/201109.mbox/%3C20110908072256.GN25324@ted.stsp.name%3E
describes what happens.
Making the sasl_callback_t structure static should be enough to guarantee
that the data will stay around long enough.
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 2c4d44c..41d5eab 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -1325,7 +1325,7 @@ static gboolean spice_channel_perform_auth_sasl(SpiceChannel *channel)
char *localAddr = NULL, *remoteAddr = NULL;
const void *val;
sasl_ssf_t ssf;
- sasl_callback_t saslcb[] = {
+ static const sasl_callback_t saslcb[] = {
{ .id = SASL_CB_PASS },
{ .id = 0 },
};
commit 4802c76c88356e859da42f78e257441a4f620ce1
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Wed Oct 16 18:33:11 2013 +0200
Display g_debug messages when SPICE_DEBUG is set
When SPICE_DEBUG is set but --spice-debug is not used, we fail
to set G_MESSAGES_DEBUG to the log domain used by spice-gtk, which
causes debug messages not to be printed as one would expect.
diff --git a/gtk/spice-util.c b/gtk/spice-util.c
index 82c5faa..21dfced 100644
--- a/gtk/spice-util.c
+++ b/gtk/spice-util.c
@@ -41,6 +41,20 @@
static GOnce debug_once = G_ONCE_INIT;
+static void spice_util_enable_debug_messages(void)
+{
+#if GLIB_CHECK_VERSION(2, 31, 0)
+ const gchar *doms = g_getenv("G_MESSAGES_DEBUG");
+ if (!doms) {
+ g_setenv("G_MESSAGES_DEBUG", G_LOG_DOMAIN, 1);
+ } else if (!strstr(doms, G_LOG_DOMAIN)) {
+ gchar *newdoms = g_strdup_printf("%s %s", doms, G_LOG_DOMAIN);
+ g_setenv("G_MESSAGES_DEBUG", newdoms, 1);
+ g_free(newdoms);
+ }
+#endif
+}
+
/**
* spice_util_set_debug:
* @enabled: %TRUE or %FALSE
@@ -56,24 +70,22 @@ void spice_util_set_debug(gboolean enabled)
*/
spice_util_get_debug();
-#if GLIB_CHECK_VERSION(2, 31, 0)
if (enabled) {
- const gchar *doms = g_getenv("G_MESSAGES_DEBUG");
- if (!doms) {
- g_setenv("G_MESSAGES_DEBUG", G_LOG_DOMAIN, 1);
- } else if (!strstr(doms, G_LOG_DOMAIN)) {
- gchar *newdoms = g_strdup_printf("%s %s", doms, G_LOG_DOMAIN);
- g_setenv("G_MESSAGES_DEBUG", newdoms, 1);
- g_free(newdoms);
- }
+ spice_util_enable_debug_messages();
}
-#endif
+
debug_once.retval = GINT_TO_POINTER(enabled);
}
static gpointer getenv_debug(gpointer data)
{
- return GINT_TO_POINTER(g_getenv("SPICE_DEBUG") != NULL);
+ gboolean debug;
+
+ debug = (g_getenv("SPICE_DEBUG") != NULL);
+ if (debug)
+ spice_util_enable_debug_messages();
+
+ return GINT_TO_POINTER(debug);
}
gboolean spice_util_get_debug(void)
commit 964c5bfdc0829ab2ed113cb198abbd9298cdb67d
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Wed Oct 16 18:26:46 2013 +0200
Fix --spice-debug
If spice_util_set_debug() gets called before spice_util_get_debug(),
then the value set using spice_util_set_debug() will be overridden
by the result of g_getenv("SPICE_DEBUG") != NULL the first time
spice_util_get_debug() is called.
This causes remote-viewer --spice-debug to not enable debug as
advertised if SPICE_DEBUG is not set.
An alternate fix would have been to set debug_once.status to
G_ONCE_STATUS_READY but then we would lose the thread-safety
guarantees GOnce gives us.
diff --git a/gtk/spice-util.c b/gtk/spice-util.c
index 4372f28..82c5faa 100644
--- a/gtk/spice-util.c
+++ b/gtk/spice-util.c
@@ -49,6 +49,13 @@ static GOnce debug_once = G_ONCE_INIT;
**/
void spice_util_set_debug(gboolean enabled)
{
+ /* Make sure debug_once has been initialised
+ * with the value of SPICE_DEBUG already, otherwise
+ * spice_util_get_debug() may overwrite the value
+ * that was just set using spice_util_set_debug()
+ */
+ spice_util_get_debug();
+
#if GLIB_CHECK_VERSION(2, 31, 0)
if (enabled) {
const gchar *doms = g_getenv("G_MESSAGES_DEBUG");
More information about the Spice-commits
mailing list