Opened 8 years ago

Closed 8 years ago

#9714 closed Patch - Bug Fix (fixed)

mythwelcome hanging (MythSystemUnix::Fork child QString use leads to possible deadlock)

Reported by: naf@… Owned by: beirdo
Priority: minor Milestone: 0.25
Component: MythTV - MythSystem Version: Master Head
Severity: medium Keywords:
Cc: Ticket locked: no

Description

I noticed mythwelcome sporadically hanging when calling mythstatus. Logs ended like:

2011-04-07 20:08:19.377 Locking input devices
2011-04-07 20:08:19.386 Launching: /usr/local/bin/mythshutdown --status 0
2011-04-07 20:08:19.388 Managed child (PID: 27773) has started! * command=/usr/local/bin/mythshutdown --status 0, timeout=0

Backtrace of the hung process looked like:

#0  0x00007fe8f25d81ac in __lll_lock_wait () from /lib64/libpthread.so.0
#1  0x00007fe8f25d34bf in _L_lock_1058 () from /lib64/libpthread.so.0
#2  0x00007fe8f25d331b in pthread_mutex_lock () from /lib64/libpthread.so.0
#3  0x0000003c2d2978a9 in ?? () from /usr/lib64/libGL.so.1
#4  0x0000003c2d29a8b9 in ?? () from /usr/lib64/libGL.so.1
#5  0x0000003c2d29ace8 in ?? () from /usr/lib64/libGL.so.1
#6  0x0000003c2da0098d in ?? () from /usr/lib64/tls/libnvidia-tls.so.260.19.29
#7  0x00000031338b6623 in QString::fromLatin1_helper(char const*, int) () from /usr/lib64/libQtCore.so.4
#8  0x00000031338b92bd in QString::fromAscii_helper(char const*, int) () from /usr/lib64/libQtCore.so.4
#9  0x00007fe8f445902d in QString (this=0x1ffb5b0, timeout=0) at /usr/include/QtCore/qstring.h:426
#10 GetSetting (this=0x1ffb5b0, timeout=0) at mythsystem.h:86
#11 GetSetting (this=0x1ffb5b0, timeout=0) at mythsystem.h:147
#12 MythSystemUnix::Fork (this=0x1ffb5b0, timeout=0) at system-unix.cpp:766
#13 0x00007fe8f43d1732 in MythSystem::Run (this=0x201e6b0, timeout=0) at mythsystem.cpp:152
#14 0x00007fe8f43d58c6 in myth_system (command=..., flags=<value optimized out>, timeout=0) at mythsystem.cpp:368
#15 0x0000000000404ba1 in isRunning (program=0x40f770 "mythtranscode") at main.cpp:196
#16 0x00000000004052a6 in getStatus (bWantRecStatus=false) at main.cpp:231
#17 0x000000000040e8f1 in main (argc=3, argv=0x7fffeb559068) at main.cpp:932

So the deadlock was happening in MythSystemUnix::Fork() doing QString stuff during a call to GetSetting?() between fork() and execl().

It appears that bac42c09 fixed possible child deadlocks by removing all QString use between fork() and execl() [and added comments referencing their danger!], but another QString was reintroduced in 7bad51a1.

Attached patch moves the GetSetting?() call (and thus the use of QString) to before the fork(), which solved my intermittent mythwelcome freezes.

Attachments (1)

remove_qstring_from_forked_child.diff (1.1 KB) - added by naf@… 8 years ago.

Download all attachments as: .zip

Change History (2)

Changed 8 years ago by naf@…

comment:1 Changed 8 years ago by naf

Milestone: unknown0.25
Resolution: fixed
Status: newclosed

Fix QString in forked child in mythsystem

Fixes #9714. Patch from the ticket. Thanks.

Signed-off-by: Gavin Hurlbut <ghurlbut@…>

Changeset: e355fe8471024aa026f6194a451c9b767d88bc32

Note: See TracTickets for help on using tickets.