[mythtv-commits] Ticket #2865: Calling mythfrontend with option -display results in segmentation fault

MythTV mythtv at cvs.mythtv.org
Wed Jan 3 19:14:35 UTC 2007


#2865: Calling mythfrontend with option -display results in segmentation fault
---------------------------------+------------------------------------------
 Reporter:  m.brekhof at gmail.com  |       Owner:  ijr    
     Type:  defect               |      Status:  new    
 Priority:  minor                |   Milestone:  unknown
Component:  mythtv               |     Version:  0.20   
 Severity:  medium               |  
---------------------------------+------------------------------------------
 Running mythfrontend (0.20) with commandline argument -display :0 from a
 virtual console results in a segmentation fault right after it fails to
 open the display checking for xinerama support with the function
 GetNumberOfXineramaScreens in the file:
 ''mythtv-0.20/libs/libmyth/util-x11.cpp''.

 Problem is calling the Xinerama function '''XineramaQueryExtension''' in
 the file ''libs/libmyth/util-x11.cpp'' with a Display structure that is
 non-existing. Through numerous other functions in Xorg (version 7.1) the
 call finally segfaults in the Xlib function '''XQueryExtension''' when it
 tries to lock the display.

 I have fixed the segmentation fault by checking if the structure is not
 NULL before calling '''XQueryExtension.''' The fix is included as a patch
 attached to this bugreport.

 Although the fix results in a working system I am not sure if this is the
 correct fix.
 The problem occurs when calling mythfrontend with the display option (e.g.
 -display :1) and X is not available on the current display (i.e. executing
 mythfrontend from a virtual console). The reason that this results in a
 segfault is that before the commandline arguments are parsed in the main
 function of mythfrontend (programs/mythfrontend/main.cpp)
 '''GetNumberOfXineramaScreens()''' gets called through the '''init()'''
 method of class MythContext (main.cpp line 797) which calls the
 '''Init()''' method of the class MythContextPrivate which calls
 '''GetScreenBounds()''' (mythcontext.cpp line 441) which finally calls
 GetNumberOfXineramaScreens(). Hence, the first time
 '''MythXOpenDisplay()''' is called it tries to open a display that does
 not exist. The second time (ofcourse only possible after the patch has
 been applied) '''MythXOpenDisplay()''' gets called, the commandline
 arguments have been parsed and the correct display is opened which
 succeeds. Now I believe the real problem is that the display settings are
 set through '''gContext->SetX11Display()''' (main.cpp line 1057) which
 however requires gContext to be initialized first. I figure that the egg
 should come before the chicken but then again I'm not sure
 ([http://en.wikipedia.org/wiki/Chicken-and-egg_problem#Biological_Answers
 Chicken-and-egg_problem]).



 Output mythfrontend:

 bash-3.1# mythfrontend -display :0[[BR]]
 Qt: Locales not supported on X server[[BR]]
 2005-03-04 23:03:10.583 Using runtime prefix = /usr[[BR]]
 2005-03-04 23:03:10.615 DPMS is disabled.[[BR]]
 2005-03-04 23:03:10.708 New DB connection, total: 1[[BR]]
 2005-03-04 23:03:10.759 Connected to database 'mythconverg' at host:
 10.0.0.16[[BR]]
 2005-03-04 23:03:10.764 Total desktop dim: 640x480, with 1
 screen[s].[[BR]]
 2005-03-04 23:03:10.765 MythXOpenDisplay() failed[[BR]]
 Segmentation fault (core dumped)[[BR]]
 bash-3.1#[[BR]]



 GDB output:

 (gdb) run -display :0[[BR]]
 Starting program: /usr/bin/mythfrontend -display :0[[BR]]
 [Thread debugging using libthread_db enabled][[BR]]
 [New Thread -1241478656 (LWP 837)][[BR]]
 Qt: Locales not supported on X server[[BR]]
 2005-03-04 22:44:49.047 Using runtime prefix = /usr[[BR]]
 2005-03-04 22:44:49.077 DPMS is disabled.[[BR]]
 2005-03-04 22:44:49.161 New DB connection, total: 1[[BR]]
 2005-03-04 22:44:49.629 Connected to database 'mythconverg' at host:
 10.0.0.16[[BR]]
 2005-03-04 22:44:49.634 Total desktop dim: 640x480, with 1
 screen[s].[[BR]]
 2005-03-04 22:44:49.636 MythXOpenDisplay() failed[[BR]]
 [[BR]]
 Program received signal SIGSEGV, Segmentation fault.[[BR]]
 [Switching to Thread -1241478656 (LWP 837)][[BR]]
 0xb63d316a in XQueryExtension () from /usr/lib/libX11.so.6[[BR]]
 (gdb) quit[[BR]]



 Output GDB logging (gdb.txt):

 bash-3.1# more gdb.txt[[BR]]
 [Thread debugging using libthread_db enabled][[BR]]
 [New Thread -1240692224 (LWP 834)][[BR]]
 [[BR]]
 Program exited with code 01.[[BR]]
 Current language:  auto; currently c[[BR]]

-- 
Ticket URL: <http://svn.mythtv.org/trac/ticket/2865>
MythTV <http://www.mythtv.org/>
MythTV


More information about the mythtv-commits mailing list