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 709651 - Double free when running tests
Double free when running tests
Status: RESOLVED FIXED
Product: grilo
Classification: Other
Component: core
unspecified
Other Linux
: Normal normal
: ---
Assigned To: grilo-maint
grilo-maint
Depends on:
Blocks:
 
 
Reported: 2013-10-08 15:05 UTC by Michal Hruby
Modified: 2013-11-01 22:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
net: mockup requester should be initialized/finalized once (1.78 KB, patch)
2013-10-29 18:38 UTC, Juan A. Suarez Romero
committed Details | Review

Description Michal Hruby 2013-10-08 15:05:19 UTC
We encountered a double free segfault when running tests of lp:mediascanner, and it turned that it's because of calling unload_plugin multiple times (after each test).

The stacktrace can be seen here:

Program received signal SIGABRT, Aborted.
__libc_do_syscall ()
    at ../ports/sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:44
44	../ports/sysdeps/unix/sysv/linux/arm/libc-do-syscall.S: No such file or directory.
(gdb) bt
  • #0 __libc_do_syscall
    at ../ports/sysdeps/unix/sysv/linux/arm/libc-do-syscall.S line 44
  • #1 __GI_raise
    at ../nptl/sysdeps/unix/sysv/linux/raise.c line 56
  • #2 __GI_abort
    at abort.c line 90
  • #3 __libc_message
    at ../sysdeps/unix/sysv/linux/libc_fatal.c line 199
  • #4 malloc_printerr
  • #5 _int_free
    at malloc.c line 3779
  • #6 finalize_mock_requester
    at grl-net-mock.c line 262
  • #7 grl_net_wc_finalize
    at grl-net-wc.c line 359
  • #8 g_object_unref
    from /usr/lib/arm-linux-gnueabihf/libgobject-2.0.so.0
  • #9 grl_tmdb_source_finalize
    at grl-tmdb.c line 354
  • #10 g_object_unref
    from /usr/lib/arm-linux-gnueabihf/libgobject-2.0.so.0
  • #11 grl_registry_unregister_source
    at grl-registry.c line 728
  • #12 grl_registry_unload_plugin
    at grl-registry.c line 1224
  • #13 mediascanner::GriloPluginEnvironment::TearDown
    at /home/phablet/mediascanner/tests/testlib/environments.cpp line 297
  • #14 testing::internal::TearDownEnvironment
    at /usr/src/gtest/src/gtest.cc line 4140
  • #15 std::for_each<std::reverse_iterator<__gnu_cxx::__normal_iterator<testing::Environment**, std::vector<testing::Environment*, std::allocator<testing::Environment*> > > >, void
  • #16 testing::internal::UnitTestImpl::RunAllTests
    at /usr/src/gtest/src/gtest.cc line 4250
  • #17 testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>
  • #18 testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>
  • #19 testing::UnitTest::Run
  • #20 main
    at /home/phablet/mediascanner/tests/auto/metadataresolvertest.cpp line 124


And this patch seems to fix the issue:

--- grilo.org/libs/net/grl-net-mock.c   2013-09-18 01:18:10 +0000
+++ grilo/libs/net/grl-net-mock.c       2013-10-08 13:57:12 +0000
@@ -256,14 +256,17 @@
 {
   if (config) {
     g_key_file_unref (config);
+    config = NULL;
   }
 
   if (base_path) {
     g_free (base_path);
+    base_path = NULL;
   }
 
   if (ignored_parameters) {
     g_regex_unref (ignored_parameters);
+    ignored_parameters = NULL;
   }
 }
Comment 1 Juan A. Suarez Romero 2013-10-29 18:38:25 UTC
Created attachment 258480 [details] [review]
net: mockup requester should be initialized/finalized once

The mockup requester is shared among all GrlNet instances. So it should be
initialized just once, and finalized also once, when no instance require it.
Comment 2 Juan A. Suarez Romero 2013-11-01 22:42:45 UTC
commit d6d53aa07af55ff5c348f6c71eec17d403289786
Author: Juan A. Suarez Romero <jasuarez@igalia.com>
Date:   Tue Oct 29 18:36:42 2013 +0000

    net: mockup requester should be initialized/finalized once
    
    The mockup requester is shared among all GrlNet instances. So it should be
    initialized just once, and finalized also once, when no instance require it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709651

 libs/net/grl-net-mock.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)