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 621838 - Actually add cwd to platform data
Actually add cwd to platform data
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-06-17 00:15 UTC by Colin Walters
Modified: 2010-06-18 17:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Actually add cwd to platform data (4.90 KB, patch)
2010-06-17 00:16 UTC, Colin Walters
none Details | Review
[GApplication] Add working directory to platform data (4.58 KB, patch)
2010-06-18 16:13 UTC, Colin Walters
committed Details | Review

Description Colin Walters 2010-06-17 00:15:59 UTC
This patch causes random hangs I haven't been able to debug yet.
Comment 1 Colin Walters 2010-06-17 00:16:00 UTC
Created attachment 163880 [details] [review]
Actually add cwd to platform data
Comment 2 Colin Walters 2010-06-17 18:28:50 UTC
Test case:

(cd gio/tests && ./testapp) &
(cd gio/tests && ./testapp) # should exit immediately; after hangs waiting for reply
Comment 3 Colin Walters 2010-06-17 19:10:27 UTC
========================================================================
GDBus-debug:Message:
  >>>> SENT D-Bus message (213 bytes)
  Type:    method-call
  Flags:   none
  Version: 0
  Serial:  3
  Headers:
    path -> objectpath '/org/gtk/test/app'
    interface -> 'org.gtk.Application'
    member -> 'Activate'
    destination -> 'org.gtk.test.app'
    signature -> signature 'aaya{sv}'
  Body: (@aay [], {'cwd': <'/src/jhbuild/checkout/glib/gio/tests'>})
  UNIX File Descriptors:
    (none)
  0000: 6c 01 00 01  3d 00 00 00  03 00 00 00  81 00 00 00    l...=...........
  0010: 08 01 67 00  08 61 61 79  61 7b 73 76  7d 00 00 00    ..g..aaya{sv}...
  0020: 01 01 6f 00  11 00 00 00  2f 6f 72 67  2f 67 74 6b    ..o...../org/gtk
  0030: 2f 74 65 73  74 2f 61 70  70 00 00 00  00 00 00 00    /test/app.......
  0040: 03 01 73 00  08 00 00 00  41 63 74 69  76 61 74 65    ..s.....Activate
  0050: 00 00 00 00  00 00 00 00  02 01 73 00  13 00 00 00    ..........s.....
  0060: 6f 72 67 2e  67 74 6b 2e  41 70 70 6c  69 63 61 74    org.gtk.Applicat
  0070: 69 6f 6e 00  00 00 00 00  06 01 73 00  10 00 00 00    ion.......s.....
  0080: 6f 72 67 2e  67 74 6b 2e  74 65 73 74  2e 61 70 70    org.gtk.test.app
  0090: 00 00 00 00  00 00 00 00  00 00 00 00  35 00 00 00    ............5...
  00a0: 03 00 00 00  63 77 64 00  01 73 00 00  24 00 00 00    ....cwd..s..$...
  00b0: 2f 73 72 63  2f 6a 68 62  75 69 6c 64  2f 63 68 65    /src/jhbuild/che
  00c0: 63 6b 6f 75  74 2f 67 6c  69 62 2f 67  69 6f 2f 74    ckout/glib/gio/t
  00d0: 65 73 74 73  00                                       ests.

Breakpoint 2, IA__g_dbus_message_new_from_blob (blob=0x7ffff0001f40 "l\001", blob_len=229, capabilities=G_DBUS_CAPABILITY_FLAGS_NONE, 
    error=0x7ffff7322ae8) at gdbusmessage.c:1326
1326	  g_variant_unref (headers);
(gdb) del 2
(gdb) list
1321	                     "{yv}",
1322	                     &header_field,
1323	                     &value);
1324	      g_dbus_message_set_header (message, header_field, value);
1325	    }
1326	  g_variant_unref (headers);
1327	
1328	  signature = g_dbus_message_get_header (message, G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE);
1329	  if (signature != NULL)
1330	    {
(gdb) n
1328	  signature = g_dbus_message_get_header (message, G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE);
(gdb) 
1329	  if (signature != NULL)
(gdb) fini
Run till exit from #0  IA__g_dbus_message_new_from_blob (blob=0x7ffff0001f40 "l\001", blob_len=229, 
    capabilities=G_DBUS_CAPABILITY_FLAGS_NONE, error=0x7ffff7322ae8) at gdbusmessage.c:1329
0x00007ffff760caec in _g_dbus_worker_do_read_cb (input_stream=0x612320, res=0x7ffff0003ea0, user_data=0x61c190) at gdbusprivate.c:585
585	          message = g_dbus_message_new_from_blob ((guchar *) worker->read_buffer,
Value returned is $5 = (GDBusMessage *) 0x0
(gdb) p error
$6 = (GError *) 0x7ffff0001d60
(gdb) p *$
$7 = {domain = 157, code = 13, message = 0x7ffff0006fb0 "Invalid seek request"}
(gdb)
Comment 4 David Zeuthen (not reading bugmail) 2010-06-17 20:16:47 UTC
OK, I've committed this

 http://git.gnome.org/browse/glib/commit/?id=0c506f200a60124197e8c20507a86516bb950ec4

which helps debug such issues (would have saved you a couple of hours I guess). With this patch, I get this output

(process:20840): GLib-GIO-WARNING **: Error decoding D-Bus message of 228 bytes
The error is: Unexpected early end-of-stream
The payload is as follows:
  0000: 6c 01 00 01  3c 00 00 00  03 00 00 00  98 00 00 00    l...<...........
  0010: 08 01 67 00  08 61 61 79  61 7b 73 76  7d 00 00 00    ..g..aaya{sv}...
  0020: 01 01 6f 00  11 00 00 00  2f 6f 72 67  2f 67 74 6b    ..o...../org/gtk
  0030: 2f 74 65 73  74 2f 61 70  70 00 00 00  00 00 00 00    /test/app.......
  0040: 03 01 73 00  08 00 00 00  41 63 74 69  76 61 74 65    ..s.....Activate
  0050: 00 00 00 00  00 00 00 00  02 01 73 00  13 00 00 00    ..........s.....
  0060: 6f 72 67 2e  67 74 6b 2e  41 70 70 6c  69 63 61 74    org.gtk.Applicat
  0070: 69 6f 6e 00  00 00 00 00  06 01 73 00  10 00 00 00    ion.......s.....
  0080: 6f 72 67 2e  67 74 6b 2e  74 65 73 74  2e 61 70 70    org.gtk.test.app
  0090: 00 00 00 00  00 00 00 00  07 01 73 00  07 00 00 00    ..........s.....
  00a0: 3a 31 2e 33  35 30 38 00  00 00 00 00  34 00 00 00    :1.3508.....4...
  00b0: 03 00 00 00  63 77 64 00  01 73 00 00  23 00 00 00    ....cwd..s..#...
  00c0: 2f 68 6f 6d  65 2f 64 61  76 69 64 7a  2f 48 61 63    /home/davidz/Hac
  00d0: 6b 69 6e 67  2f 67 6c 69  62 2f 67 69  6f 2f 74 65    king/glib/gio/te
  00e0: 73 74 73 00                                           sts.

while the other process says this

========================================================================
GDBus-debug:Message:
  >>>> SENT D-Bus message (212 bytes)
  Type:    method-call
  Flags:   none
  Version: 0
  Serial:  3
  Headers:
    path -> objectpath '/org/gtk/test/app'
    interface -> 'org.gtk.Application'
    member -> 'Activate'
    destination -> 'org.gtk.test.app'
    signature -> signature 'aaya{sv}'
  Body: (@aay [], {'cwd': <'/home/davidz/Hacking/glib/gio/tests'>})
  UNIX File Descriptors:
    (none)
  0000: 6c 01 00 01  3c 00 00 00  03 00 00 00  81 00 00 00    l...<...........
  0010: 08 01 67 00  08 61 61 79  61 7b 73 76  7d 00 00 00    ..g..aaya{sv}...
  0020: 01 01 6f 00  11 00 00 00  2f 6f 72 67  2f 67 74 6b    ..o...../org/gtk
  0030: 2f 74 65 73  74 2f 61 70  70 00 00 00  00 00 00 00    /test/app.......
  0040: 03 01 73 00  08 00 00 00  41 63 74 69  76 61 74 65    ..s.....Activate
  0050: 00 00 00 00  00 00 00 00  02 01 73 00  13 00 00 00    ..........s.....
  0060: 6f 72 67 2e  67 74 6b 2e  41 70 70 6c  69 63 61 74    org.gtk.Applicat
  0070: 69 6f 6e 00  00 00 00 00  06 01 73 00  10 00 00 00    ion.......s.....
  0080: 6f 72 67 2e  67 74 6b 2e  74 65 73 74  2e 61 70 70    org.gtk.test.app
  0090: 00 00 00 00  00 00 00 00  00 00 00 00  34 00 00 00    ............4...
  00a0: 03 00 00 00  63 77 64 00  01 73 00 00  23 00 00 00    ....cwd..s..#...
  00b0: 2f 68 6f 6d  65 2f 64 61  76 69 64 7a  2f 48 61 63    /home/davidz/Hac
  00c0: 6b 69 6e 67  2f 67 6c 69  62 2f 67 69  6f 2f 74 65    king/glib/gio/te
  00d0: 73 74 73 00                                           sts.

Now to investigate where the real bug really is...
Comment 5 David Zeuthen (not reading bugmail) 2010-06-17 20:36:07 UTC
Here's a way to reproduce the bug:

diff --git a/gio/tests/gdbus-serialization.c b/gio/tests/gdbus-serialization.c
index 3a49f07..edd7a76 100644
--- a/gio/tests/gdbus-serialization.c
+++ b/gio/tests/gdbus-serialization.c
@@ -647,6 +647,15 @@ message_serialize_complex (void)
                        "value 1:   array:\n"
                        "value 2:   array:\n"
                        "    string: `Something'\n");
+
+  /* https://bugzilla.gnome.org/show_bug.cgi?id=621838 */
+  check_serialization (g_variant_new_parsed ("(@aay [], {'cwd': <'/home/davidz/
+                       "value 0:   array:\n"
+                       "value 1:   array:\n"
+                       "    dict_entry:\n"
+                       "      string: `cwd'\n"
+                       "      variant:\n"
+                       "        string: `/home/davidz/Hacking/glib/gio/tests'\n
 }


$ ./gdbus-serialization 
/gdbus/message-serialize-basic: OK
/gdbus/message-serialize-complex: **
ERROR:gdbus-serialization.c:563:check_serialization: assertion failed (error == NULL): Unexpected early end-of-stream (g-io-error-quark, 0)
Aborted

I'll commit this test case along with the fix (for bisectability, 'make check' should _always_ pass)... still working on the fix..
Comment 6 David Zeuthen (not reading bugmail) 2010-06-17 22:03:10 UTC
The GDBus problem should be fixed with this commit

http://git.gnome.org/browse/glib/commit/?id=79d32c2fc18dcd62e9e12ca871676d35697c9d41

Colin, does this work for you? Cheers, David
Comment 7 Christian Persch 2010-06-18 11:51:05 UTC
+ * On all platforms, @data will have a key "cwd" of type
+ * signature "s" which contains the working directory of the invoked
+ * executable (unless the working directory is not representable in UTF-8, in
+ * which case the key will not be included).

I don't like this. What's wrong with using "ay" for the cwd, so cwd can _always_ be sent? For example, gnome-terminal sends cwd too, and uses "ay".
Also, if there was an argument for "s" over "ay" why would that not also apply for "as" over "aay", for argv (which quite correctly _does_ use "aay") ?

Also, how about another guaranteed key: "display-name" containing gdk_display_get_name (gdk_display_get_default()) (type "ay").
Comment 8 Colin Walters 2010-06-18 13:45:35 UTC
(In reply to comment #7)
> + * On all platforms, @data will have a key "cwd" of type
> + * signature "s" which contains the working directory of the invoked
> + * executable (unless the working directory is not representable in UTF-8, in
> + * which case the key will not be included).
> 
> I don't like this. What's wrong with using "ay" for the cwd, so cwd can
> _always_ be sent? For example, gnome-terminal sends cwd too, and uses "ay".
> Also, if there was an argument for "s" over "ay" why would that not also apply
> for "as" over "aay", for argv (which quite correctly _does_ use "aay") ?

The problem with that was that on win32, I don't have a GLib function to give me a non-UTF8 cwd.  I guess we can just have special code for windows.

> Also, how about another guaranteed key: "display-name" containing
> gdk_display_get_name (gdk_display_get_default()) (type "ay").

That'd be in GtkApplication (and thus a separate bug), but sure.
Comment 9 Colin Walters 2010-06-18 16:13:59 UTC
Created attachment 164019 [details] [review]
[GApplication] Add working directory to platform data
Comment 10 Matthias Clasen 2010-06-18 17:02:27 UTC
Comment on attachment 164019 [details] [review]
[GApplication] Add working directory to platform data

Looks good to me.
Comment 11 Colin Walters 2010-06-18 17:05:24 UTC
Attachment 164019 [details] pushed as 8f5bde6 - [GApplication] Add working directory to platform data