/* gcc youcantlockthis.c -o youcantlockthis $(pkg-config --cflags --libs glib-2.0) */

/*
 * Example program causing deadlock in g_variant_ref_sink()
 *
 * mikkel.kamstrup@canonical.com
 */

#include <glib.h>
#include <glib/gprintf.h>

gint
main ()
{
  GVariant *v;
  gchar    *s;
  
  v = g_variant_new ("(si)", "foo", 27);
  s = g_variant_print (v, FALSE);
  
  g_variant_unref (v);
  g_variant_ref_sink (v); // <- deadlock
  
  g_printf ("Variant: %s\n", s);
  g_free (s);
  g_variant_unref (v);

  return 0;
}

