v15 reading epg in existing db crashes
#1
I have the problem, that reading EPG information on startup or when enabling LiveTV leads to a crash, if an EPG* database file exists in ~/.kodi/userdata/Database/
Reading EPG information after deleting the database files before works fine.


- I use a self compiled version of kodi based on the release 15.0b1-Isengard.
- The pvr.hts plugin was compiled regarding chapter4 in Readme.linux (make command).
Unfortunately I don't have the version number of the addon here - I'll look later and add this information.
- Linux 15.04 running on Odroid-XU3

Yesterday I already debugged the crash and it happens while trying to insert EPG Information into the sqlite DB.
Somehow it lookes like an stack problem, Local variables looks first destroyed but after up/down in gdb they look fine.

Before I go deeper into this topic: Is this a known issue and already solved in later releases?
Should I better upgrade to the latest commit in the master branch?

Pls. let me know if you need more information,
Reply
#2
No sure if this is related but,
I have the similar issue with the EPG and TvHeadend clients running on Isengard across 4 different OS platforms.
No crash on startup, but if I try and look at the EPG it will crash Kodi Isengard immediately.

I've just compiled latest master Isengard with TvHeadend client v2.1.8. on iOS for the iPad.
The good news is no more EPG crashing issues. Smile

Isengard nightly with TvHeadend Client v2.1.9 on the RPi2 = EPG / Kodi crash
I don't know what to make of it.

No issues with Helix.

Reply
#3
Can you guys post your crash logs?
Reply
#4
I'll need some time for it cause I have messed up my system completely and reimaged it - this evening is possible
Reply
#5
Typical, - enabled Debug Logging and rebooted the RPi2

Then what do you know OpenElec Build #612 and TvHeadend v2.19 and the EPG is working. First time in quite a while.
Smile

Reply
#6
crashlog is:
https://www.dropbox.com/s/vnphkyq6bl72gl...9.log?dl=0

Interesting is that it doesn't happen always, -O3 more often then -O0.
Always the same channels are loaded into EPG DB
If I select "dont use DB for EPG" in settings, everything is fine.
Once the database is corruptes it normally segfaults on every start.
I'll push the Epg10.db and Epg10.db-journal also into my dropbox folder https://www.dropbox.com/sh/wc2dgpuzcd3n6...F_GYa?dl=0.

I'll now make one crash with debugger attached and can provide the backrace after that.

Versions:

-The last kodi commit was d1a2c33b6c477badb8b9664e8897523a78da91b4
-Sources are: https://github.com/mapfau/xbmc, there are some changes rearding MFC for exynos devices, but no changes in LiveTV
-PVR Addon version is HTS_VERSION=2.1.7

Code:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xa2fff3f0 (LWP 19137)]
0xb4ed2fba in std::string::assign(std::string const&) () from /usr/lib/arm-linux-gnueabihf/libstdc++.so.6
(gdb) bt
#0  0xb4ed2fba in std::string::assign(std::string const&) () from /usr/lib/arm-linux-gnueabihf/libstdc++.so.6
#1  0x00b76ece in dbiplus::SqliteDataset::make_query (this=0xa26127f0, _sql=Python Exception <class 'ValueError'> Cannot find type dbiplus::StringList::_Node:
std::list) at sqlitedataset.cpp:495
#2  0x00b7709a in dbiplus::SqliteDataset::make_insert (this=0xa26127f0) at sqlitedataset.cpp:521
#3  0x00b6a97e in dbiplus::Dataset::post (this=0xa26127f0) at dataset.cpp:299
#4  0x00b62bcc in CDatabase::CommitInsertQueries (this=0x1dbfbd0 <EPG::CEpgContainer::Get()::epgInstance+560>) at Database.cpp:287
#5  0x00bb7cc2 in EPG::CEpgDatabase::Persist (this=0x1dbfbd0 <EPG::CEpgContainer::Get()::epgInstance+560>, epgs=Python Exception <class 'ValueError'> Cannot find type const std::map<unsigned int, EPG::CEpg*, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, EPG::CEpg*> > >::_Rep_type:
std::map with 364 elements) at EpgDatabase.cpp:305
#6  0x00bb0ec4 in EPG::CEpgContainer::PersistTables (this=0x1dbf9a0 <EPG::CEpgContainer::Get()::epgInstance>) at EpgContainer.cpp:245
#7  0x00d43a04 in PVR::CPVRChannelGroupInternal::CreateChannelEpgs (this=0xa2610a60, bForce=false) at PVRChannelGroupInternal.cpp:345
#8  0x00d46666 in PVR::CPVRChannelGroups::CreateChannelEpgs (this=0xa3000890) at PVRChannelGroups.cpp:569
#9  0x00d4a626 in PVR::CPVRChannelGroupsContainer::CreateChannelEpgs (this=0xa3000570) at PVRChannelGroupsContainer.cpp:271
#10 0x00d62c92 in PVR::CPVRManager::CreateChannelEpgs (this=0x1dc29d8 <PVR::CPVRManager::Get()::pvrManagerInstance>) at PVRManager.cpp:1733
#11 0x00d5fd78 in PVR::CPVREpgsCreateJob::DoWork (this=0xa260cf60) at PVRManager.cpp:1007
#12 0x00d62840 in PVR::CPVRManager::ExecutePendingJobs (this=0x1dc29d8 <PVR::CPVRManager::Get()::pvrManagerInstance>) at PVRManager.cpp:1690
#13 0x00d5e052 in PVR::CPVRManager::Process (this=0x1dc29d8 <PVR::CPVRManager::Get()::pvrManagerInstance>) at PVRManager.cpp:545
#14 0x0184c66c in CThread::Action (this=0x1dc29e0 <PVR::CPVRManager::Get()::pvrManagerInstance+8>) at Thread.cpp:221
#15 0x0184c3e0 in CThread::staticThread (data=0x1dc29e0 <PVR::CPVRManager::Get()::pvrManagerInstance+8>) at Thread.cpp:131
#16 0xb6b7c490 in start_thread (arg=0x0) at pthread_create.c:335
#17 0xb4dc0c4c in ?? () at ../sysdeps/unix/sysv/linux/arm/clone.S:89 from /lib/arm-linux-gnueabihf/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Last but not least: I tried to get the crash with enabling / disabling LiveTV inside settings, without luck.
It seems that either on shutdown or startup something happens with the database.

[Edit] Regarding the sqlite3 documentation:
Code:
To avoid memory leaks, the application should invoke sqlite3_free() on error message strings returned through the 5th parameter of of sqlite3_exec() after the error message string is no longer needed
This is not done there with err variable in dbiplus::SqliteDataset::make_query() ...

[Edit2] Pls.let me check my git merge before you do anything
[Edit3] Merge is OK - so the issue is really an issue, I'll update to latest master today
Reply
#7
Can you reproduce with an official build?
Reply
#8
I git diffed the official branch with "my" branch, there are only 7 files different and they are all Codec specific.
Pls. let me first verify the problem with the latest master release
Reply
#9
its the same with master, i'll check now with official build.
In valgrind are printed some places with unnitialized vars - I'll check them before

[Edit] The uninitialized vars don't change the behaviour /but valgrind log looks better :-) I'll make an push request later to your repo.

I have uploaded a new log file with EPG_DEUGGING enabled (https://www.dropbox.com/s/s0ygogeah1zf24...8.log?dl=0)

It ends with:
Code:
00:25:55 T:2723148784   DEBUG: EPG - Load - no database entries found for table 'Welt der Wunder'.
00:25:55 T:2723148784   DEBUG: EPG - Load - no database entries found for table 'EinsPlus HD'.
00:25:55 T:2742019056  NOTICE: Thread EPGUpdater start, auto delete: false
00:25:55 T:2723148784  NOTICE: Start - EPG thread started
00:25:55 T:2645586928    INFO: PVRChannelGroupsContainer - SearchMissingChannelIcons - starting channel icon search
00:25:55 T:2742019056   DEBUG: persist table 'hr3' (#1458) changed=0 deleted=0
00:25:55 T:2723148784   DEBUG: CPVRChannelGroup - Persist - persisting channel group 'Alle Kan<C3><A4>le' with 52 channels
00:25:55 T:2742019056   ERROR: CommitInsertQueries - failed to execute queries
00:25:55 T:2742019056   DEBUG: persist table 'NDR 1 Radio MV' (#1459) changed=0 deleted=0
00:25:55 T:2742019056   DEBUG: persist table 'ffn digital' (#1460) changed=0 deleted=0
00:25:55 T:2742019056   DEBUG: persist table 'RTL2' (#1461) changed=0 deleted=0
00:25:55 T:2742019056   DEBUG: persist table 'domradio' (#1462) changed=0 deleted=0
00:25:55 T:2742019056   DEBUG: persist table 'hr2' (#1463) changed=0 deleted=0
00:25:55 T:2742019056   DEBUG: persist table 'DRadio Wissen' (#1464) changed=0 deleted=0
00:25:55 T:2742019056   DEBUG: persist table 'SWR4 BW' (#1465) changed=0 deleted=0
00:25:55 T:2742019056   DEBUG: persist table 'DLF' (#1466) changed=0 deleted=0
00:25:55 T:2723148784   DEBUG: CPVRChannelGroup - Persist - persisting channel group 'Alle Kan<C3><A4>le' with 52 channels

Question: Is it correct, that the last line is already processed 9 lines above?
For me it seems that multiple threads access the same list of EPG Infos....
Reply
#10
OK, got the official build compiled now (there were some GLES Init problems).
But the problem is still present with the official build. Same place where it crashes.

From debugging side:

It happens always at xbmc/dbwrappers/sqlitedataset.cpp:495

Code:
void SqliteDataset::make_query(StringList &_sql) {
  string query;
  if (db == NULL) throw DbErrors("No Database Connection");

try {

  if (autocommit) db->start_transaction();


  for (list<string>::iterator i =_sql.begin(); i!=_sql.end(); ++i) {
>>  query = *i;
  char* err=NULL;

Iterator i is invalid (sometimes 0x04 sometimes 0x08 in my tests)
_sql seems to be ok, the debugger shows a vald line, so something happens with i in the loop.

In valgrind I have seen some invalid read / writes regarding the libpython lib, do you see them also?

[Edit2] Just analized the flow of the stack trace. There is processed a std::map wich holds EPG's (in Persists()).
It seems that another thread writes into this map (PVR Addon??) while it is accessed from the sqlite DB.
I think there is a locking mechanism missing between writing EBG from client and reading EPG for DP insertion.
Reply
#11
@negge: Can anybody of you reproduce it? If so I can stop searching.....
Reply
#12
I haven't had time to look into it yet.
Reply
#13
OK, then I'll continue

[Edit] Hard stuff without really knowing what should happen...
I did some log output in xbmc/dbwrapper/dataset.cpp, this is the place where the EPG Infos are pushed into the DB.
These new log entries are prefixed with DBI and include the this pointer of the dataset:

Code:
23:09:51 T:2724197360   DEBUG: EPG - Load - no database entries found for table 'EinsPlus HD'.
23:09:51 T:2554360816  NOTICE: Thread EPGUpdater start, auto delete: false
23:09:51 T:2724197360  NOTICE: Start - EPG thread started
23:09:51 T:2646635504    INFO: PVRChannelGroupsContainer - SearchMissingChannelIcons - starting channel icon search
23:09:51 T:2554360816   DEBUG: persist table 'hr3' (#313) changed=0 deleted=0
23:09:51 T:2554360816   DEBUG: DBI - add_insert_sql - -1581147728
23:09:51 T:2554360816   DEBUG: DBI - post - -1581147728 begin
23:09:51 T:2724197360   DEBUG: DBI - add_insert_sql - -1581147728
23:09:51 T:2724197360   DEBUG: Previous line repeats 155 times.
23:09:51 T:2724197360   DEBUG: DBI - post - -1581147728 begin
23:09:51 T:2554360816   DEBUG: DBI - post - -1581147728 end
23:09:51 T:2554360816   DEBUG: EPG - clear_insert_sql - -1581147728

Good to see: Thread 2554360816 starts post(), but before it ends thread 2724197360 starts also a post on the same dataset.
Here are the interesting lines:

23:09:51 T:2554360816 DEBUG: DBI - post - -1581147728 begin
...
23:09:51 T:2724197360 DEBUG: DBI - post - -1581147728 begin
23:09:51 T:2554360816 DEBUG: DBI - post - -1581147728 end

Thread 16 must finalize this dataset before another thread can use it......

It would be great if somebody who has more knowledge about what should happen loks over this.
Let me know if you need more information.

Following the 2 backtraces fo the 2 threads both attaching the same dataset:

Code:
#0  dbiplus::Dataset::post (this=0xa1f1fe98) at dataset.cpp:304
#1  0x00762034 in CDatabase::CommitInsertQueries (this=0x187dab0 <EPG::CEpgContainer::Get()::epgInstance+560>) at Database.cpp:286
#2  0x007b35fe in EPG::CEpgDatabase::Persist (this=0x187dab0 <EPG::CEpgContainer::Get()::epgInstance+560>, epgs=Python Exception <class 'ValueError'> Cannot find type const std::map<unsigned int, EPG::CEpg*, std::less<unsigned int>, std:
:allocator<std::pair<unsigned int const, EPG::CEpg*> > >::_Rep_type:
std::map with 157 elements) at EpgDatabase.cpp:304
#3  0x007b0cce in EPG::CEpgContainer::PersistTables() ()
#4  0x00927ce8 in PVR::CPVRChannelGroupInternal::CreateChannelEpgs (this=0xa1f00930, bForce=false) at PVRChannelGroupInternal.cpp:342
#5  0x0092ab0e in PVR::CPVRChannelGroups::CreateChannelEpgs (this=0xa3a004a8) at PVRChannelGroups.cpp:569
#6  0x0092ddfe in PVR::CPVRChannelGroupsContainer::CreateChannelEpgs() ()
#7  0x00948952 in PVR::CPVRManager::CreateChannelEpgs (this=0x1880768 <PVR::CPVRManager::Get()::pvrManagerInstance>) at PVRManager.cpp:1733
#8  0x009459cc in PVR::CPVREpgsCreateJob::DoWork (this=0xa1f12570) at PVRManager.cpp:1007
#9  0x00948500 in PVR::CPVRManager::ExecutePendingJobs (this=0x1880768 <PVR::CPVRManager::Get()::pvrManagerInstance>) at PVRManager.cpp:1690
#10 0x00943d72 in PVR::CPVRManager::Process (this=0x1880768 <PVR::CPVRManager::Get()::pvrManagerInstance>) at PVRManager.cpp:545
#11 0x013bdf4e in CThread::Action() ()
#12 0x013be112 in CThread::staticThread(void*) ()
#13 0xb6b8a490 in start_thread (arg=0x0) at pthread_create.c:335
#14 0xb4dc0c4c in ?? () at ../sysdeps/unix/sysv/linux/arm/clone.S:89 from /lib/arm-linux-gnueabihf/libc.so.6
$1 = (dbiplus::Dataset * const) 0xa1f1fe98

#0  dbiplus::Dataset::post (this=0xa1f1fe98) at dataset.cpp:309
#1  0x00762034 in CDatabase::CommitInsertQueries (this=0x187dab0 <EPG::CEpgContainer::Get()::epgInstance+560>) at Database.cpp:286
#2  0x007aae2e in EPG::CEpg::Persist (this=0xa1f32ec0) at Epg.cpp:559
#3  0x007b0d7a in EPG::CEpgContainer::PersistAll() ()
#4  0x007b103a in EPG::CEpgContainer::Process() ()
#5  0x013bdf4e in CThread::Action() ()
#6  0x013be112 in CThread::staticThread(void*) ()
#7  0xb6b8a490 in start_thread (arg=0x0) at pthread_create.c:335
#8  0xb4dc0c4c in ?? () at ../sysdeps/unix/sysv/linux/arm/clone.S:89 from /lib/arm-linux-gnueabihf/libc.so.6

I'll provide an push request for this soon...
[Edit] Can you pls provide me someone to talk about pvr / epg?
I need advice if these two threads should be running parallel or if they should run completely one after the other.
Reply
#14
OK, I have fixed both issues, one was only EPG dependent (sync, see above) and one was reading Channels (PVR Section).
I'll git push them tonight - I have to cleanup all the debug output first....

[Edit] https://github.com/xbmc/xbmc/pull/7300
https://github.com/xbmc/xbmc/pull/7367
Reply
#15
Patch from 1 st link fails to apply on top of Kodi 15.0. The second one does not resolve this issue.
Could you please provide a working solution for official Kodi 15?
Reply



Logout Mark Read Team Forum Stats Members Help
reading epg in existing db crashes0
This forum uses Lukasz Tkacz MyBB addons.