Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1330127

Summary: SIGSEGV if GLib MainLoop is run from thread to e.g. capture DBus signals
Product: Red Hat Enterprise Linux 7 Reporter: Jaroslav Škarvada <jskarvad>
Component: dbusAssignee: David King <dking>
Status: CLOSED NOTABUG QA Contact: Desktop QE <desktop-qa-list>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.2CC: vbenes
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-04-26 16:14:04 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Reproducer none

Description Jaroslav Škarvada 2016-04-25 12:38:10 UTC
Created attachment 1150443 [details]
Reproducer

Description of problem:
It seems the code lacks locking somewhere. I am currently not sure whether it is DBus or GLib issue, but as it is hanging in the libdbus I am filling the bug against DBus.

Version-Release number of selected component (if applicable):
dbus-libs-1.6.12-13.el7.x86_64

How reproducible:
Always

Steps to Reproduce:
1. for (( i=1; i < 1000; i++ )); do ./test.py; done

Actual results:
Often SIGSEGVs

Expected results:
No SIGSEGVs

Additional info:
It works OK on fedora (e.g. dbus-libs-1.10.8-1.fc23.x86_64).

Comment 1 Jaroslav Škarvada 2016-04-25 12:39:55 UTC
Backtrace:

#0  link_before (link=link@entry=0x1efa9b8, before_this_link=0x7f590000, list=list@entry=0x1f7b020) at dbus-list.c:120
#1  _dbus_list_prepend_link (list=list@entry=0x1f7b020, link=link@entry=0x1efa9b8) at dbus-list.c:325
#2  0x00007f5954b26fe9 in _dbus_list_append_link (list=list@entry=0x1f7b020, link=link@entry=0x1efa9b8) at dbus-list.c:307
#3  0x00007f5954b1748f in _dbus_message_add_counter_link (message=message@entry=0x1f7afb0, link=link@entry=0x1efa9b8) at dbus-message.c:304
#4  0x00007f5954b1750f in _dbus_message_add_counter (message=0x1f7afb0, counter=0x20736b0) at dbus-message.c:338
#5  0x00007f5954b23849 in _dbus_transport_queue_messages (transport=transport@entry=0x206a3c0) at dbus-transport.c:1140
#6  0x00007f5954b241e6 in do_reading (transport=0x206a3c0) at dbus-transport-socket.c:851
#7  0x00007f5954b248f6 in socket_do_iteration (transport=0x206a3c0, flags=6, timeout_milliseconds=<optimized out>) at dbus-transport-socket.c:1162
#8  0x00007f5954b235ff in _dbus_transport_do_iteration (transport=0x206a3c0, flags=32483768, flags@entry=6, timeout_milliseconds=360, timeout_milliseconds@entry=25000)
    at dbus-transport.c:976
#9  0x00007f5954b0cd7c in _dbus_connection_do_iteration_unlocked (connection=connection@entry=0x1f6bd50, pending=pending@entry=0x1efaa40, flags=flags@entry=6, 
    timeout_milliseconds=timeout_milliseconds@entry=25000) at dbus-connection.c:1234
#10 0x00007f5954b0d75d in _dbus_connection_block_pending_call (pending=0x1efaa40) at dbus-connection.c:2415
#11 0x00007f5954b1d5fa in dbus_pending_call_block (pending=<optimized out>) at dbus-pending-call.c:748
#12 0x00007f5954b0dd3a in dbus_connection_send_with_reply_and_block (connection=0x1f6bd50, message=message@entry=0x2054940, timeout_milliseconds=timeout_milliseconds@entry=-1, 
    error=error@entry=0x7ffc0559f5f0) at dbus-connection.c:3530
#13 0x00007f5954d510df in Connection_send_message_with_reply_and_block (self=0x2033cb0, args=<optimized out>) at ../../_dbus_bindings/conn-methods.c:498
#14 0x00007f595cc89bd4 in call_function (oparg=<optimized out>, pp_stack=0x7ffc0559f760) at /usr/src/debug/Python-2.7.5/Python/ceval.c:4098
#15 PyEval_EvalFrameEx (
    f=f@entry=Frame 0x213ad40, for file /usr/lib64/python2.7/site-packages/dbus/connection.py, line 651, in call_blocking (self=<unknown at remote 0x2033cb0>, bus_name='org.freedesktop.DBus', object_path='/org/freedesktop/DBus', dbus_interface='org.freedesktop.DBus', method='GetNameOwner', signature='s', args=('com.redhat.tuned',), timeout=<float at remote 0x1e3bee8>, byte_arrays=False, kwargs={'utf8_strings': True}, get_args_opts={'byte_arrays': False, 'utf8_strings': True}, message=<dbus.lowlevel.MethodCallMessage at remote 0x7f595d1005a0>), 
    throwflag=throwflag@entry=0) at /usr/src/debug/Python-2.7.5/Python/ceval.c:2740
#16 0x00007f595cc8b1ed in PyEval_EvalCodeEx (co=<optimized out>, globals=<optimized out>, locals=locals@entry=0x0, args=args@entry=0x2035378, argcount=7, kws=kws@entry=0x1fb0650, 
    kwcount=kwcount@entry=1, defs=defs@entry=0x7f595d05fe78, defcount=defcount@entry=2, closure=0x0) at /usr/src/debug/Python-2.7.5/Python/ceval.c:3330
#17 0x00007f595cc181bd in function_call (func=<function at remote 0x7f595cfef7d0>, arg=<unknown at remote 0x2035360>, kw=<unknown at remote 0x1f7b640>)
    at /usr/src/debug/Python-2.7.5/Objects/funcobject.c:526
#18 0x00007f595cbf30c3 in PyObject_Call (func=func@entry=<function at remote 0x7f595cfef7d0>, arg=arg@entry=<unknown at remote 0x2035360>, kw=kw@entry=<unknown at remote 0x1f7b640>)
    at /usr/src/debug/Python-2.7.5/Objects/abstract.c:2529
#19 0x00007f595cc86427 in ext_do_call (nk=<optimized out>, na=<optimized out>, flags=<optimized out>, pp_stack=0x7ffc0559fa20, func=<function at remote 0x7f595cfef7d0>)
    at /usr/src/debug/Python-2.7.5/Python/ceval.c:4411
#20 PyEval_EvalFrameEx (
    f=f@entry=Frame 0x213aa20, for file /usr/lib64/python2.7/site-packages/dbus/bus.py, line 361, in get_name_owner (self=<unknown at remote 0x2033cb0>, bus_name='com.redhat.tuned', keywords=<unknown at remote 0x1f7b640>), throwflag=throwflag@entry=0) at /usr/src/debug/Python-2.7.5/Python/ceval.c:2779
#21 0x00007f595cc89990 in fast_function (nk=<optimized out>, na=2, n=2, pp_stack=0x7ffc0559fb80, func=<function at remote 0x7f595cfefed8>) at /usr/src/debug/Python-2.7.5/Python/ceval.c:4184
#22 call_function (oparg=<optimized out>, pp_stack=0x7ffc0559fb80) at /usr/src/debug/Python-2.7.5/Python/ceval.c:4119
#23 PyEval_EvalFrameEx (
    f=f@entry=Frame 0x213a820, for file /usr/lib64/python2.7/site-packages/dbus/bus.py, line 175, in activate_name_owner (self=<unknown at remote 0x2033cb0>, bus_name='com.redhat.tuned'), 
    throwflag=throwflag@entry=0) at /usr/src/debug/Python-2.7.5/Python/ceval.c:2740
#24 0x00007f595cc89990 in fast_function (nk=<optimized out>, na=2, n=2, pp_stack=0x7ffc0559fce0, func=<function at remote 0x7f595cfefb18>) at /usr/src/debug/Python-2.7.5/Python/ceval.c:4184
#25 call_function (oparg=<optimized out>, pp_stack=0x7ffc0559fce0) at /usr/src/debug/Python-2.7.5/Python/ceval.c:4119
#26 PyEval_EvalFrameEx (
    f=f@entry=Frame 0x1f29730, for file /usr/lib64/python2.7/site-packages/dbus/proxies.py, line 248, in __init__ (self=<unknown at remote 0x20f7310>, conn=<unknown at remote 0x2033cb0>, bus_name='com.redhat.tuned', object_path='/Tuned', introspect='com.redhat.tuned.control', follow_name_owner_changes=False, kwargs={}, bus=None, named_service=None), 
    throwflag=throwflag@entry=0) at /usr/src/debug/Python-2.7.5/Python/ceval.c:2740
#27 0x00007f595cc8b1ed in PyEval_EvalCodeEx (co=<optimized out>, globals=<optimized out>, locals=locals@entry=0x0, args=args@entry=0x7f595d0ae958, argcount=4, kws=kws@entry=0x203aa08, 
    kwcount=kwcount@entry=2, defs=defs@entry=0x7f595cfe52a8, defcount=defcount@entry=5, closure=0x0) at /usr/src/debug/Python-2.7.5/Python/ceval.c:3330
#28 0x00007f595cc181bd in function_call (func=<function at remote 0x7f595cfee230>, arg=(<unknown at remote 0x20f7310>, <unknown at remote 0x2033cb0>, 'com.redhat.tuned', '/Tuned'), 
    kw={'introspect': 'com.redhat.tuned.control', 'follow_name_owner_changes': False}) at /usr/src/debug/Python-2.7.5/Objects/funcobject.c:526
#29 0x00007f595cbf30c3 in PyObject_Call (func=func@entry=<function at remote 0x7f595cfee230>, 
    arg=arg@entry=(<unknown at remote 0x20f7310>, <unknown at remote 0x2033cb0>, 'com.redhat.tuned', '/Tuned'), 
    kw=kw@entry={'introspect': 'com.redhat.tuned.control', 'follow_name_owner_changes': False}) at /usr/src/debug/Python-2.7.5/Objects/abstract.c:2529
#30 0x00007f595cc020b5 in instancemethod_call (func=<function at remote 0x7f595cfee230>, arg=(<unknown at remote 0x20f7310>, <unknown at remote 0x2033cb0>, 'com.redhat.tuned', '/Tuned'), 
    kw={'introspect': 'com.redhat.tuned.control', 'follow_name_owner_changes': False}) at /usr/src/debug/Python-2.7.5/Objects/classobject.c:2602
#31 0x00007f595cbf30c3 in PyObject_Call (func=func@entry=<instancemethod at remote 0x7f595d122b40>, arg=arg@entry=<unknown at remote 0x20178c0>, 
    kw=kw@entry={'introspect': 'com.redhat.tuned.control', 'follow_name_owner_changes': False}) at /usr/src/debug/Python-2.7.5/Objects/abstract.c:2529
#32 0x00007f595cc4a187 in slot_tp_init (self=<optimized out>, args=<unknown at remote 0x20178c0>, kwds={'introspect': 'com.redhat.tuned.control', 'follow_name_owner_changes': False})
    at /usr/src/debug/Python-2.7.5/Objects/typeobject.c:5692
#33 0x00007f595cc48e9f in type_call (type=<optimized out>, args=<unknown at remote 0x20178c0>, kwds={'introspect': 'com.redhat.tuned.control', 'follow_name_owner_changes': False})
    at /usr/src/debug/Python-2.7.5/Objects/typeobject.c:745
#34 0x00007f595cbf30c3 in PyObject_Call (func=func@entry=<type at remote 0x1f6c980>, arg=arg@entry=<unknown at remote 0x20178c0>, 
    kw=kw@entry={'introspect': 'com.redhat.tuned.control', 'follow_name_owner_changes': False}) at /usr/src/debug/Python-2.7.5/Objects/abstract.c:2529
#35 0x00007f595cc8738c in do_call (nk=<optimized out>, na=3, pp_stack=0x7ffc055a02c0, func=<type at remote 0x1f6c980>) at /usr/src/debug/Python-2.7.5/Python/ceval.c:4316
#36 call_function (oparg=<optimized out>, pp_stack=0x7ffc055a02c0) at /usr/src/debug/Python-2.7.5/Python/ceval.c:4121
#37 PyEval_EvalFrameEx (
    f=f@entry=Frame 0x1f293e0, for file /usr/lib64/python2.7/site-packages/dbus/bus.py, line 241, in get_object (self=<unknown at remote 0x2033cb0>, bus_name='com.redhat.tuned', object_path='/Tuned', introspect='com.redhat.tuned.control', follow_name_owner_changes=False, kwargs={}, named_service=None), throwflag=throwflag@entry=0)
    at /usr/src/debug/Python-2.7.5/Python/ceval.c:2740
#38 0x00007f595cc8b1ed in PyEval_EvalCodeEx (co=<optimized out>, globals=<optimized out>, locals=locals@entry=0x0, args=<optimized out>, argcount=argcount@entry=4, kws=0x1ee2d78, 
    kwcount=0, defs=0x7f595d05ff08, defcount=2, closure=closure@entry=0x0) at /usr/src/debug/Python-2.7.5/Python/ceval.c:3330
#39 0x00007f595cc8989f in fast_function (nk=<optimized out>, na=4, n=4, pp_stack=0x7ffc055a04c0, func=<function at remote 0x7f595cfefb90>) at /usr/src/debug/Python-2.7.5/Python/ceval.c:4194
#40 call_function (oparg=<optimized out>, pp_stack=0x7ffc055a04c0) at /usr/src/debug/Python-2.7.5/Python/ceval.c:4119
#41 PyEval_EvalFrameEx (f=f@entry=Frame 0x1ee2be0, for file ./test.py, line 17, in <module> (), throwflag=throwflag@entry=0) at /usr/src/debug/Python-2.7.5/Python/ceval.c:2740
#42 0x00007f595cc8b1ed in PyEval_EvalCodeEx (co=co@entry=0x7f595d0c39b0, 
    globals=globals@entry={'GLib': <unknown at remote 0x2031610>, 'DBusGMainLoop': <built-in function DBusGMainLoop>, 'dbus': <module at remote 0x7f595d079bb0>, 'thread': <unknown at remote 0x2031d90>, '__builtins__': <module at remote 0x7f595d140b08>, 'bus': <unknown at remote 0x2033cb0>, '__file__': './test.py', 'main_loop': <unknown at remote 0x207fe88>, '__package__': None, 'threading': <module at remote 0x7f595d0837f8>, 'time': <module at remote 0x7f595d079328>, '__name__': '__main__', '__doc__': None, 'thread_code': <unknown at remote 0x20f8410>}, 
    locals=locals@entry={'GLib': <unknown at remote 0x2031610>, 'DBusGMainLoop': <built-in function DBusGMainLoop>, 'dbus': <module at remote 0x7f595d079bb0>, 'thread': <unknown at remote 0x2031d90>, '__builtins__': <module at remote 0x7f595d140b08>, 'bus': <unknown at remote 0x2033cb0>, '__file__': './test.py', 'main_loop': <unknown at remote 0x207fe88>, '__package__': None, 'threading': <module at remote 0x7f595d0837f8>, 'time': <module at remote 0x7f595d079328>, '__name__': '__main__', '__doc__': None, 'thread_code': <unknown at remote 0x20f8410>}, 
    args=args@entry=0x0, argcount=argcount@entry=0, kws=kws@entry=0x0, kwcount=kwcount@entry=0, defs=defs@entry=0x0, defcount=defcount@entry=0, closure=closure@entry=0x0)
    at /usr/src/debug/Python-2.7.5/Python/ceval.c:3330
#43 0x00007f595cc8b2f2 in PyEval_EvalCode (co=co@entry=0x7f595d0c39b0, 
    globals=globals@entry={'GLib': <unknown at remote 0x2031610>, 'DBusGMainLoop': <built-in function DBusGMainLoop>, 'dbus': <module at remote 0x7f595d079bb0>, 'thread': <unknown at remote 0x2031d90>, '__builtins__': <module at remote 0x7f595d140b08>, 'bus': <unknown at remote 0x2033cb0>, '__file__': './test.py', 'main_loop': <unknown at remote 0x207fe88>, '__package__': None, 'threading': <module at remote 0x7f595d0837f8>, 'time': <module at remote 0x7f595d079328>, '__name__': '__main__', '__doc__': None, 'thread_code': <unknown at remote 0x20f8410>}, 
    locals=locals@entry={'GLib': <unknown at remote 0x2031610>, 'DBusGMainLoop': <built-in function DBusGMainLoop>, 'dbus': <module at remote 0x7f595d079bb0>, 'thread': <unknown at remote 0x2031d90>, '__builtins__': <module at remote 0x7f595d140b08>, 'bus': <unknown at remote 0x2033cb0>, '__file__': './test.py', 'main_loop': <unknown at remote 0x207fe88>, '__package__': None, 'threading': <module at remote 0x7f595d0837f8>, 'time': <module at remote 0x7f595d079328>, '__name__': '__main__', '__doc__': None, 'thread_code': <unknown at remote 0x20f8410>})
    at /usr/src/debug/Python-2.7.5/Python/ceval.c:689
#44 0x00007f595cca472f in run_mod (mod=<optimized out>, filename=filename@entry=0x7ffc055a13ec "./test.py", 
    globals=globals@entry={'GLib': <unknown at remote 0x2031610>, 'DBusGMainLoop': <built-in function DBusGMainLoop>, 'dbus': <module at remote 0x7f595d079bb0>, 'thread': <unknown at remote 0x2031d90>, '__builtins__': <module at remote 0x7f595d140b08>, 'bus': <unknown at remote 0x2033cb0>, '__file__': './test.py', 'main_loop': <unknown at remote 0x207fe88>, '__package__': None, 'threading': <module at remote 0x7f595d0837f8>, 'time': <module at remote 0x7f595d079328>, '__name__': '__main__', '__doc__': None, 'thread_code': <unknown at remote 0x20f8410>}, 
    locals=locals@entry={'GLib': <unknown at remote 0x2031610>, 'DBusGMainLoop': <built-in function DBusGMainLoop>, 'dbus': <module at remote 0x7f595d079bb0>, 'thread': <unknown at remote 0x2031d90>, '__builtins__': <module at remote 0x7f595d140b08>, 'bus': <unknown at remote 0x2033cb0>, '__file__': './test.py', 'main_loop': <unknown at remote 0x207fe88>, '__package__': None, 'threading': <module at remote 0x7f595d0837f8>, 'time': <module at remote 0x7f595d079328>, '__name__': '__main__', '__doc__': None, 'thread_code': <unknown at remote 0x20f8410>}, 
    flags=flags@entry=0x7ffc055a0720, arena=arena@entry=0x1e5ef30) at /usr/src/debug/Python-2.7.5/Python/pythonrun.c:1374
#45 0x00007f595cca58ee in PyRun_FileExFlags (fp=fp@entry=0x1ee7240, filename=filename@entry=0x7ffc055a13ec "./test.py", start=start@entry=257, 
    globals=globals@entry={'GLib': <unknown at remote 0x2031610>, 'DBusGMainLoop': <built-in function DBusGMainLoop>, 'dbus': <module at remote 0x7f595d079bb0>, 'thread': <unknown at remote 0x2031d90>, '__builtins__': <module at remote 0x7f595d140b08>, 'bus': <unknown at remote 0x2033cb0>, '__file__': './test.py', 'main_loop': <unknown at remote 0x207fe88>, '__package__': None, 'threading': <module at remote 0x7f595d0837f8>, 'time': <module at remote 0x7f595d079328>, '__name__': '__main__', '__doc__': None, 'thread_code': <unknown at remote 0x20f8410>}, 
    locals=locals@entry={'GLib': <unknown at remote 0x2031610>, 'DBusGMainLoop': <built-in function DBusGMainLoop>, 'dbus': <module at remote 0x7f595d079bb0>, 'thread': <unknown at remote 0x2031d90>, '__builtins__': <module at remote 0x7f595d140b08>, 'bus': <unknown at remote 0x2033cb0>, '__file__': './test.py', 'main_loop': <unknown at remote 0x207fe88>, '__package__': None, '
threading': <module at remote 0x7f595d0837f8>, 'time': <module at remote 0x7f595d079328>, '__name__': '__main__', '__doc__': None, 'thread_code': <unknown at remote 0x20f8410>}, 
    closeit=closeit@entry=1, flags=flags@entry=0x7ffc055a0720) at /usr/src/debug/Python-2.7.5/Python/pythonrun.c:1360
#46 0x00007f595cca6b79 in PyRun_SimpleFileExFlags (fp=fp@entry=0x1ee7240, filename=filename@entry=0x7ffc055a13ec "./test.py", closeit=closeit@entry=1, flags=flags@entry=0x7ffc055a0720)
    at /usr/src/debug/Python-2.7.5/Python/pythonrun.c:952
#47 0x00007f595cca7093 in PyRun_AnyFileExFlags (fp=fp@entry=0x1ee7240, filename=filename@entry=0x7ffc055a13ec "./test.py", closeit=closeit@entry=1, flags=flags@entry=0x7ffc055a0720)
    at /usr/src/debug/Python-2.7.5/Python/pythonrun.c:756
#48 0x00007f595ccb7caf in Py_Main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/Python-2.7.5/Modules/main.c:640
#49 0x00007f595bee4b15 in __libc_start_main (main=0x4006f0 <main>, argc=2, ubp_av=0x7ffc055a08e8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, 
    stack_end=0x7ffc055a08d8) at libc-start.c:274
#50 0x0000000000400721 in _start ()

Comment 2 David King 2016-04-26 16:14:04 UTC
This does not seem like a dbus bug, but something in your code that you need to fix, or possibly something in the dbus Python bindings or maybe even dbus-glib. You can ask on the upstream mailing list for support, if you need assistance developing thread-safe code which uses dbus:

https://lists.freedesktop.org/mailman/listinfo/dbus

You should note the documentation for dbus-glib threading support:

https://dbus.freedesktop.org/doc/dbus-glib/dbus-glib-DBusGConnection.html#dbus-g-thread-init

Specifically, the part that reads "Note that dbus-glib's GObject mapping is explicitly *not* thread-safe." and "dbus-glib is never thread-safe". You should additionally note the dbus-python documentation:

https://pypi.python.org/pypi/dbus-python

Specifically, the part that states "[dbus-python] uses libdbus (which has known problems with multi-threaded use)"