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 739780 - name cut off
name cut off
Status: RESOLVED OBSOLETE
Product: gnome-logs
Classification: Other
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gnome-logs maintainer(s)
gnome-logs maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-11-07 13:49 UTC by William Jon McCann
Modified: 2018-05-22 13:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
screenshot (553.00 KB, image/png)
2014-11-07 13:49 UTC, William Jon McCann
  Details
use "kernel" as the name of kernel-generated log messages (1.54 KB, patch)
2015-02-06 01:45 UTC, Jonathan Kang
rejected Details | Review
parse _CMDLINE to name log messages (7.91 KB, patch)
2015-02-07 03:49 UTC, Jonathan Kang
needs-work Details | Review
parse _CMDLINE to name log messages (8.03 KB, patch)
2015-02-14 13:26 UTC, Jonathan Kang
needs-work Details | Review
parse _CMDLINE to name log messages (7.82 KB, patch)
2015-02-15 14:09 UTC, Jonathan Kang
needs-work Details | Review
parse _CMDLINE to name log messages (7.82 KB, patch)
2015-02-15 15:19 UTC, Jonathan Kang
needs-work Details | Review

Description William Jon McCann 2014-11-07 13:49:20 UTC
Created attachment 290163 [details]
screenshot

It seems like the name of the executable is getting truncated.
Comment 1 David King 2014-11-07 14:03:42 UTC
It seems that _COMM is limited to 16 characters, which you can see by listing /proc/<pid>/comm (which is presumably what journald does to fill the _COMM field).

It is probably easiest to fetch and parse _CMDLINE instead.
Comment 2 Jonathan Kang 2015-02-06 01:45:47 UTC
Created attachment 296248 [details] [review]
use "kernel" as the name of kernel-generated log messages

kernel-generated log messages don't have _COMM and _CMDLINE. So it's not useful to parse _CMDLINE, we can name these log messages as "kernel".
Comment 3 David King 2015-02-06 11:21:57 UTC
Review of attachment 296248 [details] [review]:

Any message can have a _COMM that is empty, as argv can be changed by the application at runtime (or the process can simply write to /proc/[pid]/comm), so this is not a correct fix. Also, it is not a fix for this bug, which is about extending the application name for each message to be longer than 16 characters, if available. Kernel messages should be checked with the _TRANSPORT field.
Comment 4 Jonathan Kang 2015-02-07 03:49:59 UTC
Created attachment 296314 [details] [review]
parse _CMDLINE to name log messages

I didn't fully get the main idea of the bug. Sorry for that.
Here's the patch for parsing _CMDLINE to name log messages. I don't have enough kinds of log messages to test it. Hope you can help test this patch.
Comment 5 David King 2015-02-11 14:37:59 UTC
Review of attachment 296314 [details] [review]:

This lead to reproducible crashes for me, when selecting the details view with certain entries, so will need a bit more work.

::: src/gl-eventviewrow.c
@@ +108,2 @@
 static void
+gl_event_view_row_parse_cmdline (GlEventViewRow *row)

This should accept a "gchar *" (or even a "const gchar *") rather than a GlEventViewRow, and return a gchar *. This would make it much easier to test, as the test would not have to contruct a complete GlEventViewRow just to test the cmdline parsing.
Comment 6 Jonathan Kang 2015-02-14 13:26:14 UTC
Created attachment 296825 [details] [review]
parse _CMDLINE to name log messages

I fixed the problem, and this patch should work.
Comment 7 David King 2015-02-14 14:49:51 UTC
Review of attachment 296825 [details] [review]:

::: src/gl-eventviewrow.c
@@ +119,3 @@
+    {
+        str = strtok (str2, "/");
+        while ((str = strtok (NULL, "/")) != NULL)

Leave a blank line before the while.

@@ +126,3 @@
+    else
+    {
+		rtn = str1;

Odd indentation here.

@@ +128,3 @@
+		rtn = str1;
+        str = strtok (str1, "/");
+        while ((str = strtok (NULL, "/")) != NULL)

Leave a blank line before the while.

@@ +162,3 @@
     gtk_container_add (GTK_CONTAINER (row), grid);
 
+    result->cmdline = gl_event_view_row_parse_cmdline (result->cmdline);

Now that result->cmdline has been changed, it is not possible to call g_free() on it (as it does not necessarily point to the same location). You will probably need to accept a const gchar * in _parse_cmdline(), and return a duplicated string, taking care to free result->cmdline as necessary.

::: src/gl-eventviewrow.h
@@ +59,3 @@
 GtkWidget * gl_event_view_row_new (GlJournalResult *result, GlEventViewRowStyle style, GlUtilClockFormat clock_format);
 GlJournalResult * gl_event_view_row_get_result (GlEventViewRow *row);
+gchar * gl_event_view_row_parse_cmdline (gchar *cmdline);

Why did you add this function to the header? It is not used in any other file, and so should be static.

::: src/gl-journal.c
@@ +293,3 @@
     }
 
+	result->cmdline = gl_journal_get_data (self, "_CMDLINE", &error);

Odd indentation.
Comment 8 Jonathan Kang 2015-02-15 14:09:20 UTC
Created attachment 296874 [details] [review]
parse _CMDLINE to name log messages

Fixed a few things. And here is the patch.
Comment 9 David King 2015-02-15 14:22:26 UTC
Review of attachment 296874 [details] [review]:

This doesn't fix the issue that I mentioned before. Make gl_event_view_row_parse_cmdline() accept a "const gchar *", and that should solve the problem.
Comment 10 Jonathan Kang 2015-02-15 15:02:17 UTC
If the argument of _parse_cmdline() is const type, there will be a warning that g_strtok ignores const while compiling.
Comment 11 David King 2015-02-15 15:04:06 UTC
Correct. You need to adjust the code until there is not a warning.
Comment 12 Jonathan Kang 2015-02-15 15:19:20 UTC
Created attachment 296877 [details] [review]
parse _CMDLINE to name log messages

This should work.
Comment 13 David King 2015-02-15 16:30:29 UTC
Comment on attachment 296877 [details] [review]
parse _CMDLINE to name log messages

@@ -130,8 +163,9 @@ gl_event_view_row_create_cmdline (GlEventViewRow *row)
     gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
     gtk_container_add (GTK_CONTAINER (row), grid);

+    result->cmdline = gl_event_view_row_parse_cmdline (result->cmdline);
     markup = g_markup_printf_escaped ("<b>%s</b>",
-                                      result->comm ? result->comm : "");

This is a memory leak. You need to be careful to avoid them.
Comment 14 Lars Karlitski 2015-02-15 20:25:07 UTC
Parsing command lines is hard. Can't we just use _EXE and call g_path_get_basename() on it?
Comment 15 David King 2015-02-15 20:34:02 UTC
The problem with _EXE is that it points to the interpreter for Python (and bash, and…) scripts.
Comment 16 Lars Karlitski 2015-02-15 21:01:38 UTC
Hm, good point. But I don't see a way around that. There's no way to tell which argument is the name of the script. The attached patch guesses it's always the second argument, but only if it starts with '/'. Sometimes that's not true, and sometimes there's no script name at all. For example, I use this all the time:

  python3 -m http.server

I think I'd want the full command line in that case. Maybe we should just always show that?

Also, are we going to need this at all once bug #727895 is fixed? The new design doesn't seem to show program name at all.
Comment 17 David King 2015-02-15 21:11:26 UTC
The details view (accessed by clicking on a row) shows an icon for the application, if a (admittedly, very crude) lookup against COMM matches a desktop file. Where a desktop file is not available, the application name is shown, if available. The examples given in this report could be solved by querying the systemd service name.

It is really hard to unambiguously match a log message with an "application" at the moment, but if we restrict the definition of an application to something well-defined then we should be fine. It is easiest to request that applications inject extra metadata into the journal for the purposes of matching an application with a desktop file, or maybe this is something that gnome-shell or the application sandbox should be doing?
Comment 18 Jonathan Kang 2016-02-19 02:25:56 UTC
I think using SYSLOG_IDENTIFIER instead of _COMM field as the title in detail view is a better option(if no icon is shown).
Comment 19 David King 2016-02-19 09:20:24 UTC
SYSLOG_IDENTIFIER is roughly the value of _CMDLINE, so not appropriate as a replacement for COMM in several cases. Plus, we want the trusted fields, not the user fields.
Comment 20 Jonathan Kang 2016-02-19 09:41:36 UTC
(In reply to David King from comment #19)
> SYSLOG_IDENTIFIER is roughly the value of _CMDLINE, so not appropriate as a
> replacement for COMM in several cases. Plus, we want the trusted fields, not
> the user fields.

I think SYSLOG_IDENTIFIER is quite different with _CMDLINE. For example, I got such a log entry in my system:

Fri 2016-02-19 16:53:36.103845 CST [s=211df74eb4364b3ca31d9a24873f4a81;i=1dc9c;b=f5bafa6ed3644776bcfc5a1c9774b4b7;m=6f52cb379;t=52c1b9e5bb9a5;x=9d56721531592272]
    _TRANSPORT=stdout
    _UID=1000
    _GID=100
    _CAP_EFFECTIVE=0
    _AUDIT_SESSION=1
    _AUDIT_LOGINUID=1000
    _SYSTEMD_CGROUP=/user.slice/user-1000.slice/session-1.scope
    _SYSTEMD_SESSION=1
    _SYSTEMD_OWNER_UID=1000
    _SYSTEMD_UNIT=session-1.scope
    _SYSTEMD_SLICE=user-1000.slice
    _MACHINE_ID=89c660865c00403a9bacef32b6828556
    _HOSTNAME=sckang
    _COMM=dbus-daemon
    _EXE=/bin/dbus-daemon
    _CMDLINE=/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
    PRIORITY=4
    SYSLOG_IDENTIFIER=org.gnome.Contacts.SearchProvider
    _PID=1760
    _BOOT_ID=f5bafa6ed3644776bcfc5a1c9774b4b7
    MESSAGE=(gnome-contacts-search-provider:17557): Gtk-CRITICAL **: gtk_list_store_insert_before: assertion 'iter_is_valid (sibling, list_store)' failed

SYSLOG_IDENTIFIER provides a more accurate information of the log entry than _COMM and _CMDLINE. Yep, SYSLOG_IDENTIFIER is not a trusted field. :-(
Comment 21 GNOME Infrastructure Team 2018-05-22 13:03:02 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gnome-logs/issues/7.