Opened 11 years ago

Closed 11 years ago

#6358 closed defect (fixed)

checkTimeZone() with old backends can crash

Reported by: Nigel Owned by: Isaac Richards
Priority: minor Milestone: unknown
Component: MythTV - General Version: unknown
Severity: medium Keywords:
Cc: Ticket locked: no

Description

% ./mythbackend                   
2009-03-15 21:17:12.301 mythbackend version: trunk [20210M] www.mythtv.org
2009-03-15 21:17:12.305 Using runtime prefix = /Volumes/MythBuild/.osx-packager/src/myth-svn/mythtv/programs/Resources
2009-03-15 21:17:12.305 Using localhost value of macaque.ind.tansu.com.au
2009-03-15 21:17:12.307 Testing network connectivity to 192.168.0.14
2009-03-15 21:17:12.343 New DB connection, total: 1
2009-03-15 21:17:12.359 Connected to database 'mythconverg' at host: 192.168.0.14
2009-03-15 21:17:12.359 Closing DB connection named 'DBManager0'
2009-03-15 21:17:12.360 Connected to database 'mythconverg' at host: 192.168.0.14
zsh: bus error  ./mythbackend

% gdb ./mythbackend
...
(gdb) run -v all
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /Volumes/MythBuild/.osx-packager/src/myth-svn/mythtv/programs/mythbackend/mythbackend -v all
2009-03-15 21:18:01.048 mythbackend version: trunk [20210M] www.mythtv.org
...
2009-03-15 21:18:01.106 MSqlQuery::exec() "SELECT data FROM settings WHERE value = 'MasterServerPort' AND hostname IS NULL;"
2009-03-15 21:18:01.107 MythSocket(212c430:9): attempting connect() to (192.168.0.14:6543)
2009-03-15 21:18:01.107 MythSocket(212c430:9): state change Idle -> Connected
2009-03-15 21:18:01.107 write ->  9 21      ANN Monitor tzcheck 0
2009-03-15 21:18:01.109 read  <-  9 2       OK
2009-03-15 21:18:01.109 write ->  9 15      QUERY_TIME_ZONE
2009-03-15 21:18:01.110 read  <-  9 15      UNKNOWN_COMMAND

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x3220353d
0x01cfd109 in QLocalePrivate::numberToCLocale ()
(gdb) where
#0  0x01cfd109 in QLocalePrivate::numberToCLocale ()
#1  0x01cfe3d9 in QLocalePrivate::stringToLongLong ()
#2  0x01d115f5 in QString::toLongLong ()
#3  0x01d11677 in QString::toInt ()
#4  0xc60d554d in checkTimeZone ()
#5  0x02816800 in ?? ()
Previous frame inner to this frame (corrupt stack?)
(gdb) 

Initial debug looks like something is supplying a bad QStringList to checkTimeZone()

Change History (2)

comment:1 Changed 11 years ago by anonymous

Slightly related to [18792]. The call is coming from mythbackend's main(). It would be possible to checking the result from QUERY_TIME_ZONE, but I think it is easiest to have an earlier call to CheckProtoVersion?(), to weed out backends that are too old to support QUERY_TIME_ZONE, and this host as a slave backend:

Index: main.cpp
===================================================================
--- main.cpp    (revision 20211)
+++ main.cpp    (working copy)
@@ -826,7 +826,12 @@
                         gContext->GetSetting("MasterServerIP", "127.0.0.1"),
                         gContext->GetNumSetting("MasterServerPort", 6543)))
         {
-            QStringList tempMonitorDone("DONE");
+            if (!CheckProtoVersion(tempMonitorConnection))
+            {
+                VERBOSE(VB_IMPORTANT, "Master backend is incompatible with "
+                                      "this backend. Cannot become a slave.");
+                return BACKEND_EXIT_NO_CONNECT;
+            }
 
             QStringList tempMonitorAnnounce("ANN Monitor tzcheck 0");
             tempMonitorConnection->writeStringList(tempMonitorAnnounce);
@@ -856,6 +861,8 @@
                         QString("Backend is running in %1 time zone.")
                         .arg(getTimeZoneID()));
             }
+
+            QStringList tempMonitorDone("DONE");
             tempMonitorConnection->writeStringList(tempMonitorDone);
         }
         tempMonitorConnection->DownRef();

comment:2 Changed 11 years ago by Nigel

Resolution: fixed
Status: newclosed

(In [20214]) Check backend versions before checking timezone differences. Fixes #6358

Note: See TracTickets for help on using tickets.