|
SageTV Github Development Discussion related to SageTV Open Source Development. Use this forum for development topics about the Open Source versions of SageTV, hosted on Github. |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
Failed to parse EPG start date
Hi there,
currently, I'm finding lots of Code:
ERROR parsing EPG message start time of:java.lang.NumberFormatException: For input string: "(null)" Code:
EPG-1|41985-1101-28461 DT|(null)|17700|deu|[set=ISO-8859-9][len=12]ARD-Popnacht|[set=ISO-8859-9][len=92]1:00 - 1:03 Nachrichten2:00 - 2:03 Nachrichten3:00 - 3:03 Nachrichten4:00 - 4:03 Nachrichten||| greetings Ken |
#2
|
||||
|
||||
This is sent from the native TS parsing code when it encounters EPG data information in the stream and sends the notification back to the Java layer for integration into the database. I'm not sure what would cause the 'null' entry like that though.
__________________
Jeffrey Kardatzke Founder of SageTV |
#3
|
|||
|
|||
Digging a while, I finally found it. The EPG string is constructed in
native/ax/Native2.0/NativeCore/DVBPSIParser.c In function DVBFormatEPG the function UTCFormat (from PSIParser.c) is called. UTCFormat is defined like this: Code:
char* UTCFormat( uint32_t t, char* p, int len ) { static char utc_time[30]; struct tm *utc; utc = localtime( (const time_t *)&t ); if ( utc != NULL && utc->tm_isdst ) { t -= 3600; utc = localtime( (const time_t *)&t ); //revseral from mktime() } ... 8< (snip) ... return p; } utc = localtime( (const time_t *)&t ); time_t is a wishy-washy type, as can be read here: stackoverflow On some linux systems, one can NOT cast a uint32_t to time_t by using a pointer. Which means: Code:
uint32_t wrongTimeType = ...; localtime ( (const time_t*)&wrongTimeType ); Code:
uint32_t wrongTimeType = ...; time_t rightTimeType; rightTimeType = (time_t)wrongTimeType; localtime ( &rightTimeType ); I will check the rest of the code, if there are other calls to localtime() with the wrong time. Ken Last edited by kenfox; 01-24-2017 at 07:38 AM. Reason: Better link for explaining time_t |
#4
|
||||
|
||||
Great, thanks for tracking that down.
__________________
Jeffrey Kardatzke Founder of SageTV |
#5
|
|||
|
|||
I've checked the native folder and found occurences only in SIParser.c and PSIParser.c. I've change my code locally like this:
SIParser.c, line 1179 to 1182 Code:
//BUGFIX: Do a real cast to time_t time_t rawTime = (time_t)(pEit->start_time); //BUGFIX: Use &rawTime instead of (const time_t *)&pEit->start_time utc = localtime( &rawTime ); //revseral from mktime() Code:
//BUGFIX: Do a real cast to time_t time_t rawTime = (time_t)t; //BUGFIX: Use &rawTime instead of (const time_t *)&t utc = localtime( &rawTime ); if ( utc != NULL && utc->tm_isdst ) { t -= 3600; //BUGFIX: Use &rawTime instead of (const time_t *)&t utc = localtime( &rawTime ); //revseral from mktime() } |
#6
|
||||
|
||||
I'm not sure you'll get much feedback on someone testing a change like that. You can go ahead and submit a pull request and I'll have somebody else who knows this kind of stuff better than I do take a look and let me know if they see any problems...but to me, it looks like it's a safe change.
__________________
Jeffrey Kardatzke Founder of SageTV |
#7
|
|||
|
|||
It's pretty safe to just include since it's just casting before use but it looks like you've introduced a bug with the DST 'if' statement. You need to recast the new value of 't' into 'rawTime' after subtracting 3600:
Code:
//BUGFIX: Do a real cast to time_t time_t rawTime = (time_t)t; //BUGFIX: Use &rawTime instead of (const time_t *)&t utc = localtime( &rawTime ); if ( utc != NULL && utc->tm_isdst ) { t -= 3600; rawTime = (time_t)t; //BUGFIX: Use &rawTime instead of (const time_t *)&t utc = localtime( &rawTime ); //revseral from mktime() } |
#8
|
|||
|
|||
Yeah man, you are right! Thanx for takeing a look at it.
|
#9
|
|||
|
|||
So here is the patch. Please review it.
Code:
From e0b915b7a167e49ea0d536d32185b8c5e4a8ae81 Mon Sep 17 00:00:00 2001 From: Ken Fox <kenfox@outlook.de> Date: Thu, 2 Feb 2017 12:19:44 +0100 Subject: [PATCH 1/2] Doing a real cast for time_t, because casting a time_t pointer is dangerous --- native/ax/Native2.0/NativeCore/PSIParser.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/native/ax/Native2.0/NativeCore/PSIParser.c b/native/ax/Native2.0/NativeCore/PSIParser.c index 3429223..ff5ed10 100644 --- a/native/ax/Native2.0/NativeCore/PSIParser.c +++ b/native/ax/Native2.0/NativeCore/PSIParser.c @@ -526,12 +526,15 @@ char* UTCFormat( uint32_t t, char* p, int len ) { static char utc_time[30]; struct tm *utc; - utc = localtime( (const time_t *)&t ); + //Be shure to do a real cast: + time_t rawTime = (time_t)t; + utc = localtime( &rawTime ); if ( utc != NULL && utc->tm_isdst ) { t -= 3600; - utc = localtime( (const time_t *)&t ); //revseral from mktime() - } + rawTime = (time_t)t; + utc = localtime( &rawTime ); //revseral from mktime() + } if ( utc == NULL ) return 0; if ( p == NULL || len == 0) { -- 2.11.0.windows.1 From 6f2c33347cdadec1d3dcc3f44e282c5269fb3fa3 Mon Sep 17 00:00:00 2001 From: Ken Fox <kenfox@outlook.de> Date: Thu, 2 Feb 2017 12:25:39 +0100 Subject: [PATCH 2/2] Doing a real cast for time_t, becaus casting a time_t pointer is dangerous --- native/ax/TSnative/SIParser.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/native/ax/TSnative/SIParser.c b/native/ax/TSnative/SIParser.c index 223a325..ca37e0e 100644 --- a/native/ax/TSnative/SIParser.c +++ b/native/ax/TSnative/SIParser.c @@ -1176,7 +1176,9 @@ int EPGNotifyDVB( SI_PARSER* pParser, DEIT* pEit ) //lt = pEit->start_time - 315532800+6*3600*24; //convert to start time 1/6/1980 from 1/1/1970 //lt = pEit->start_time - 315964800; - utc = localtime( (const time_t *)&pEit->start_time ); //revseral from mktime() + //Be shure to do a real cast: + time_t rawTime = (time_t)(pEit->start_time); + utc = localtime( &rawTime ); //revseral from mktime() if ( utc == NULL ) return 0; utc->tm_hour -= utc->tm_isdst > 0 ? 1 : 0; //get ridee of saving time -- 2.11.0.windows.1 |
#10
|
|||
|
|||
Looks good to me,
|
#11
|
||||
|
||||
Go ahead and submit your pull request.
__________________
Jeffrey Kardatzke Founder of SageTV |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sorting based on released date and add to library date not working still | Gustovier | Diamond | 35 | 03-15-2011 12:45 PM |
Automatic Metadata Failed (Code 10100) IMDB: Failed to parse providerDataUrl: | mkanet | Batch Metadata Tools | 2 | 10-12-2010 03:22 PM |
How to Display Recordings by Recording Date & Original Air Date | joe123 | SageTV Customizations | 25 | 02-16-2010 05:28 AM |
6.2.4-SagetvService:timeout,failed to start | DRAK | SageTV Beta Test Software | 11 | 07-11-2007 06:05 AM |
How does 6.0.13 parse .mov and .hdmov ? | corykim | SageTV Beta Test Software | 0 | 11-13-2006 06:51 PM |