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 692360 - possibly non-threadsafe code in g_content_type_guess()?
possibly non-threadsafe code in g_content_type_guess()?
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-01-23 09:20 UTC by Akira TAGOH
Modified: 2013-01-25 04:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gcontenttype: Duplicate the string inside Mutex lock for thread-safety (836 bytes, patch)
2013-01-24 03:34 UTC, Akira TAGOH
committed Details | Review
gcontenttype: Duplicate the string inside Mutex lock for thread-safety (836 bytes, patch)
2013-01-25 04:53 UTC, Akira TAGOH
committed Details | Review

Description Akira TAGOH 2013-01-23 09:20:29 UTC
I don't have any reproducible code but just trying to see any possibilities why happened. it was originally reported at https://bugzilla.redhat.com/show_bug.cgi?id=768580

The backtrace says:
  • #0 _g_local_file_info_get
    at glocalfileinfo.c line 1655

It was segfault there. content_type should be came from g_content_type_guess() in get_content_type() in glocalfileinfo.c.

the code in question is this:

  /* Got an extension match, and no conflicts. This is it. */
  if (n_name_mimetypes == 1)
    {
      G_UNLOCK (gio_xdgmime);
      return g_strdup (name_mimetypes[0]);
    }

name_mimetypes might be broken after Mutex is unlocked if another thread enters into it. shouldn't it be:

  /* Got an extension match, and no conflicts. This is it. */
  if (n_name_mimetypes == 1)
    {
      gchar *r = g_strdup (name_mimetypes[0]);
      G_UNLOCK (gio_xdgmime);
      return r;
    }

or something like that?
Comment 1 Matthias Clasen 2013-01-23 13:28:52 UTC
You are right. Can you provide a patch ?
Comment 2 Akira TAGOH 2013-01-24 03:34:49 UTC
Created attachment 234273 [details] [review]
gcontenttype: Duplicate the string inside Mutex lock for thread-safety
Comment 3 Matthias Clasen 2013-01-25 03:48:51 UTC
Review of attachment 234273 [details] [review]:

looks good, please commit
Comment 4 Akira TAGOH 2013-01-25 04:53:53 UTC
The following fix has been pushed:
7261294 gcontenttype: Duplicate the string inside Mutex lock for thread-safety
Comment 5 Akira TAGOH 2013-01-25 04:53:59 UTC
Created attachment 234365 [details] [review]
gcontenttype: Duplicate the string inside Mutex lock for thread-safety