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 694454 - make check fails with segfault
make check fails with segfault
Status: RESOLVED FIXED
Product: GUPnP
Classification: Other
Component: gupnp
unspecified
Other Linux
: Normal normal
: ---
Assigned To: GUPnP Maintainers
GUPnP Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-02-22 15:07 UTC by Martin Pitt
Modified: 2014-12-08 16:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Indentation fix (869 bytes, patch)
2013-06-24 22:27 UTC, Olivier Crête
committed Details | Review
Make NMDevice into a refcounted structure (2.17 KB, patch)
2013-06-24 22:27 UTC, Olivier Crête
committed Details | Review
Hold references while doing async calls (5.84 KB, patch)
2013-06-24 22:27 UTC, Olivier Crête
committed Details | Review

Description Martin Pitt 2013-02-22 15:07:17 UTC
gupnp-igd consistently fails its checks in jhbuild:

make[3]: Entering directory `/home/ubuntu/gnome/checkout/gupnp-igd/tests/gtest'
/simpleigd/new: OK
/simpleigd/default_ctx: OK
/simpleigd/custom_ctx: OK
/simpleigd/thread: OK
/simpleigd/invalid_ip: /bin/bash: line 5: 31218 Segmentation fault      (core dumped) XML_PATH=. G_SLICE=debug-blocks LD_LIBRARY_PATH=../../libgupnp-igd/.libs:/home/ubuntu/gnome/packages/lib64 ${dir}$tst
FAIL: gupnp-simple-igd
======================================
1 of 1 test failed
Please report to http://www.gupnp.org/
======================================

See the full log on https://jenkins.qa.ubuntu.com/view/Raring/view/JHBuild%20Gnome/job/jhbuild-amd64-gupnp-igd/84/artifact/gupnp-igd.log, and thie previous history on https://jenkins.qa.ubuntu.com/view/Raring/view/JHBuild%20Gnome/job/jhbuild-amd64-gupnp-igd/

I can reproduce a segfault on my workstation (with full X.org, network, D-BUS etc.) as well, but it looks slightly different:

make[3]: Entering directory `/home/martin/upstream/gupnp-igd/tests/gtest'
/simpleigd/new: OK
/simpleigd/default_ctx: 
(/home/martin/upstream/gupnp-igd/tests/gtest/.libs/lt-gupnp-simple-igd:10907): GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GUPnPNetworkManager'
/bin/bash: line 5: 10907 Trace/breakpoint trap   (core dumped) XML_PATH=. G_SLICE=debug-blocks LD_LIBRARY_PATH=../../libgupnp-igd/.libs:/home/martin-scratch/gnome/lib64 ${dir}$tst
FAIL: gupnp-simple-igd
======================================
1 of 1 test failed
Comment 1 Martin Pitt 2013-02-22 15:16:02 UTC
The stack trace on my local jhbuild:

  • #1 g_log
    at gmessages.c line 1010
  • #2 g_type_check_instance_cast
    at gtype.c line 4044
  • #3 get_devices_cb
    at gupnp-network-manager.c line 545
  • #4 g_simple_async_result_complete
    at gsimpleasyncresult.c line 777
  • #5 reply_cb
    at gdbusproxy.c line 2632
  • #6 g_simple_async_result_complete
    at gsimpleasyncresult.c line 777
  • #7 g_dbus_connection_call_done
    at gdbusconnection.c line 5339
  • #8 g_simple_async_result_complete
    at gsimpleasyncresult.c line 777
  • #9 complete_in_idle_cb
    at gsimpleasyncresult.c line 789
  • #10 g_idle_dispatch
    at gmain.c line 5205
  • #11 g_main_dispatch
    at gmain.c line 3054
  • #12 g_main_context_dispatch
    at gmain.c line 3630
  • #13 g_main_context_iterate
    at gmain.c line 3701
  • #14 g_main_loop_run
    at gmain.c line 3895
  • #15 run_gupnp_simple_igd_test
    at gupnp-simple-igd.c line 324
  • #16 test_gupnp_simple_igd_default_ctx
    at gupnp-simple-igd.c line 341
  • #17 test_case_run
    at gtestutils.c line 1714
  • #18 g_test_run_suite_internal
    at gtestutils.c line 1767
  • #19 g_test_run_suite_internal
    at gtestutils.c line 1778
  • #20 g_test_run_suite
    at gtestutils.c line 1823
  • #21 g_test_run
    at gtestutils.c line 1324
  • #22 main
    at gupnp-simple-igd.c line 464

Comment 2 Olivier Crête 2013-06-24 22:26:43 UTC
This is actually a bug in GUPnP itself, the NetworkManager context manager does not hold a ref to itself while doing async calls and can get disposed of before they return. Patches for that are attached.

Then we get to another problem, the signals are emitted after the application has released all references to the ContextManager, which is kind of annoying. Probably the GUPnPContextManager should be an object that hides that fact (otherwise, we need a gupnp_context_manager_destroy() method). 

Also, there is a GCancellable inside GUPnPNetworkManager, but it is never used to cancel anything. That may be a good start.

@Martin: You may want to switch to the Linux ContextManager, as it doesn't seem to exhibit these issues.
Comment 3 Olivier Crête 2013-06-24 22:27:19 UTC
Created attachment 247686 [details] [review]
Indentation fix
Comment 4 Olivier Crête 2013-06-24 22:27:23 UTC
Created attachment 247687 [details] [review]
Make NMDevice into a refcounted structure
Comment 5 Olivier Crête 2013-06-24 22:27:27 UTC
Created attachment 247688 [details] [review]
Hold references while doing async calls
Comment 6 Jens Georg 2013-08-16 11:31:00 UTC
Comment on attachment 247686 [details] [review]
Indentation fix

Attachment 247686 [details] pushed as 78109f1 - Indentation fix
Comment 7 Jens Georg 2013-08-16 11:32:48 UTC
Attachment 247687 [details] pushed as c0fca00 - Make NMDevice into a refcounted structure
Attachment 247688 [details] pushed as a9e09f0 - Hold references while doing async calls
Comment 8 Alexander Kanavin 2014-12-08 16:10:23 UTC
The commit "Hold references while doing async calls" introduces a circular reference bug. You can't make one thing reference another, and have that other thing reference the original thing. As it stands now, creating a context manager object and then unref-ing it does not actually destroy the object.

See https://github.com/01org/dleyna-renderer/issues/149 for how this was discovered.

You should test your code with valgrind for leaks like this one, by the way.
Comment 9 Alexander Kanavin 2014-12-08 16:27:10 UTC
I filed a separate bug for this: https://bugzilla.gnome.org/show_bug.cgi?id=741257