#16609 new Bugs

Segfault in DatabaseUtils::GetDatabaseResults

Reported by: al__ Owned by:
Priority: 4 - Normal
Component: Database / Library for Videos (Movies and TV-Shows) Version: 16.0 "Jarvis" Final
Severity: Normal Keywords:
Cc: Razze, popcornmix Blocked By:
Blocking: Platform: Linux

Description

Shortly after start on Arch Linux ARM (Raspberry Pi - compile time flags: https://github.com/archlinuxarm/PKGBUILDs/blob/f601254f50cce258a2f4efcd4e72ca5da116e125/alarm/kodi-rbp-git/PKGBUILD, but final kodi version), this crash occurs every time:

(gdb) bt
#0  std::_Rb_tree_insert_and_rebalance (__insert_left=<optimized out>, __x=0x5c332080, __p=<optimized out>, __header=...) at /build/gcc/src/gcc-5-20160209/libstdc++-v3/src/c++98/tree.cc:237
#1  0x004616f4 in std::_Rb_tree_iterator<std::pair<Field const, CVariant> > std::_Rb_tree<Field, std::pair<Field const, CVariant>, std::_Select1st<std::pair<Field const, CVariant> >, std::less<Field>, std::allocator<std::pair<Field const, CVariant> > >::_M_emplace_hint_unique<std::piecewise_construct_t const&, std::tuple<Field&&>, std::tuple<> >(std::_Rb_tree_const_iterator<std::pair<Field const, CVariant> >, std::piecewise_construct_t const&, std::tuple<Field&&>&&, std::tuple<>&&) ()
#2  0x00c4f934 in DatabaseUtils::GetDatabaseResults(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<Field, std::allocator<Field> > const&, std::unique_ptr<dbiplus::Dataset, std::default_delete<dbiplus::Dataset> > const&, std::vector<std::map<Field, CVariant, std::less<Field>, std::allocator<std::pair<Field const, CVariant> > >, std::allocator<std::map<Field, CVariant, std::less<Field>, std::allocator<std::pair<Field const, CVariant> > > > >&) ()
#3  0x00c9f090 in SortUtils::SortFromDataset(SortDescription const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::unique_ptr<dbiplus::Dataset, std::default_delete<dbiplus::Dataset> > const&, std::vector<std::map<Field, CVariant, std::less<Field>, std::allocator<std::pair<Field const, CVariant> > >, std::allocator<std::map<Field, CVariant, std::less<Field>, std::allocator<std::pair<Field const, CVariant> > > > >&) ()
#4  0x0041fc18 in CVideoDatabase::GetMoviesByWhere(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, CDatabase::Filter const&, CFileItemList&, SortDescription const&) ()
#5  0x00420b84 in CVideoDatabase::GetRecentlyAddedMoviesNav(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, CFileItemList&, unsigned int) ()
#6  0x00c7be9c in CRecentlyAddedJob::UpdateVideo() ()
#7  0x00c869fc in CRecentlyAddedJob::DoWork() ()
#8  0x00c5f40c in CJobWorker::Process() ()
#9  0x017ea84c in CThread::Action() ()
#10 0x017eaafc in CThread::staticThread(void*) ()
#11 0x76b3cf98 in start_thread () from /usr/lib/libpthread.so.0
#12 0x75c8b470 in ?? () from /usr/lib/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) i locals
__xpp = 0x0
__root = @0x66686b2c: 0x0
(gdb) i args
__insert_left = <optimized out>
__x = 0x5c332080
__p = <optimized out>
__header = @0x66686b28: {_M_color = std::_S_red, _M_parent = 0x0, _M_left = 0x66686b28, _M_right = 0x66686b28}

Change History (5)

comment:1 Changed at 2016-02-26T19:05:45Z by Martijn

  • Cc Razze popcornmix added

comment:2 Changed at 2016-04-04T20:16:24+01:00 by zpon

I have a similar issue (see trace below) on Cubox-i running Arch Linux. I managed to fix it temporarily with this hack: https://github.com/zpon/xbmc-imx-git/blob/master/GetDatabaseResults.patch

#0  0x0048f9c4 in std::pair<Field const, CVariant>::pair<Field&&, 0u>(std::tuple<Field&&>&, std::tuple<>&, std::_Index_tuple<0u>, std::_Index_tuple<>) (
    __tuple2=<synthetic pointer>, __tuple1=..., this=<optimized out>)
    at /usr/include/c++/5.3.0/tuple:1172
#1  std::pair<Field const, CVariant>::pair<Field&&>(std::piecewise_construct_t, std::tuple<Field&&>, std::tuple<>) (__second=..., __first=..., 
    this=<optimized out>) at /usr/include/c++/5.3.0/tuple:1161
#2  __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<Field const, CVariant> > >::construct<std::pair<Field const, CVariant>, std::piecewise_construct_t const&, std::tuple<Field&&>, std::tuple<> >(std::pair<Field const, CVariant>*, std::piecewise_construct_t const&, std::tuple<Field&&>&&, std::tuple<>&&) (
    __p=<optimized out>, this=<optimized out>)
    at /usr/include/c++/5.3.0/ext/new_allocator.h:120
#3  std::allocator_traits<std::allocator<std::_Rb_tree_node<std::pair<Field const, CVariant> > > >::_S_construct<std::pair<Field const, CVariant>, std::piecewise_construct_t const&, std::tuple<Field&&>, std::tuple<> >(std::allocator<std::_Rb_tree_node<std::pair<Field const, CVariant> > >&, std::pair<Field const, CVariant>*, std::piecewise_construct_t const&, std::tuple<Field&&>&&, std::tuple<>&&)
    (__p=<optimized out>, __a=...)
    at /usr/include/c++/5.3.0/bits/alloc_traits.h:256
#4  std::allocator_traits<std::allocator<std::_Rb_tree_node<std::pair<Field const, CVariant> > > >::construct<std::pair<Field const, CVariant>, std::piecewise_construct_t const&, std::tuple<Field&&>, std::tuple<> >(std::allocator<std::_Rb_t---Type <return> to continue, or q <return> to quit---
ree_node<std::pair<Field const, CVariant> > >&, std::pair<Field const, CVariant>*, std::piecewise_construct_t const&, std::tuple<Field&&>&&, std::tuple<>&&) (
    __p=<optimized out>, __a=...)
    at /usr/include/c++/5.3.0/bits/alloc_traits.h:402
#5  std::_Rb_tree<Field, std::pair<Field const, CVariant>, std::_Select1st<std::pair<Field const, CVariant> >, std::less<Field>, std::allocator<std::pair<Field const, CVariant> > >::_M_construct_node<std::piecewise_construct_t const&, std::tuple<Field&&>, std::tuple<> >(std::_Rb_tree_node<std::pair<Field const, CVariant> >*, std::piecewise_construct_t const&, std::tuple<Field&&>&&, std::tuple<>&&) (__node=0x33d3be0, this=0x61cfd394)
    at /usr/include/c++/5.3.0/bits/stl_tree.h:529
#6  std::_Rb_tree<Field, std::pair<Field const, CVariant>, std::_Select1st<std::pair<Field const, CVariant> >, std::less<Field>, std::allocator<std::pair<Field const, CVariant> > >::_M_create_node<std::piecewise_construct_t const&, std::tuple<Field&&>, std::tuple<> >(std::piecewise_construct_t const&, std::tuple<Field&&>&&, std::tuple<>&&) (this=0x61cfd394)
    at /usr/include/c++/5.3.0/bits/stl_tree.h:546
#7  std::_Rb_tree<Field, std::pair<Field const, CVariant>, std::_Select1st<std::pair<Field const, CVariant> >, std::less<Field>, std::allocator<std::pair<Field const, CVariant> > >::_M_emplace_hint_unique<std::piecewise_construct_t const&, std::tuple<Field&&>, std::tuple<> >(std::_Rb_tree_const_iterator<std::pair<Field const, CVariant> >, std::piecewise_construct_t const&, std::tuple<Field&&>&&, std::tuple<>&&) (this=0x61cfd394, __pos=...)
---Type <return> to continue, or q <return> to quit---
    at /usr/include/c++/5.3.0/bits/stl_tree.h:2170
#8  0x00de1144 in std::map<Field, CVariant, std::less<Field>, std::allocator<std::pair<Field const, CVariant> > >::operator[](Field&&) (
    __k=<unknown type in /home/builder/xbmc-imx-git/src/xbmc/kodi.bin, CU 0x767f635, DIE 0x76aab94>, this=0x33b7ce0)
    at /usr/include/c++/5.3.0/bits/stl_map.h:502
#9  DatabaseUtils::GetDatabaseResults (
    mediaType=<error reading variable: Cannot access memory at address 0x6>, 
    fields=std::vector of length 0, capacity 0, 
    dataset=std::unique_ptr<dbiplus::Dataset> containing 0x33bc260, 
    results=<error reading variable: Cannot access memory at address 0x4>)
    at DatabaseUtils.cpp:372
#10 0x00e32c48 in SortUtils::SortFromDataset (sortDescription=..., 
    mediaType="movie", 
    dataset=std::unique_ptr<dbiplus::Dataset> containing 0x33bc260, 
    results=std::vector of length 0, capacity 25) at SortUtils.cpp:786
#11 0x0044a57c in CVideoDatabase::GetMoviesByWhere (
    [email protected]=0x61cfe1d0, 
    strBaseDir=<error reading variable: Cannot access memory at address 0x23>, 
    filter=..., items=..., sortDescription=..., getDetails=0, 
    [email protected]=52597584) at VideoDatabase.cpp:6443
#12 0x0044b528 in CVideoDatabase::GetRecentlyAddedMoviesNav (
    [email protected]=0x61cfe1d0, 
---Type <return> to continue, or q <return> to quit---
    strBaseDir=<error reading variable: Cannot access memory at address 0x23>, 
    items=..., [email protected]=0, [email protected]=0)
    at VideoDatabase.cpp:6756
#13 0x0182de94 in XFILE::VIDEODATABASEDIRECTORY::CDirectoryNodeRecentlyAddedMovies::GetContent (this=0x32299c0, items=...)
    at DirectoryNodeRecentlyAddedMovies.cpp:38
#14 0x018291bc in XFILE::VIDEODATABASEDIRECTORY::CDirectoryNode::GetChilds (
    [email protected]=0x3229350, items=...) at DirectoryNode.cpp:263
#15 0x008c7818 in XFILE::CVideoDatabaseDirectory::GetDirectory (
    this=<optimized out>, url=..., items=...) at VideoDatabaseDirectory.cpp:55
#16 0x008713f8 in XFILE::CDirectory::GetDirectory (url=..., items=..., 
    hints=..., [email protected]=false) at Directory.cpp:206
#17 0x0087420c in XFILE::CDirectory::GetDirectory (
    strPath="videodb://recentlyaddedmovies/", items=..., hints=..., 
    [email protected]=false) at Directory.cpp:130
#18 0x008742b4 in XFILE::CDirectory::GetDirectory (
    strPath="videodb://recentlyaddedmovies/", items=..., strMask="", 
    [email protected]=0, [email protected]=false)
    at Directory.cpp:124
#19 0x009c02a4 in CDirectoryJob::DoWork (this=0x3400938)
    at DirectoryProvider.cpp:79
#20 0x00df121c in CJobWorker::Process (this=0x2df5c88) at JobManager.cpp:66
#21 0x0197f810 in CThread::Action (this=0x2df5c88) at Thread.cpp:221
---Type <return> to continue, or q <return> to quit---
#22 0x0197fac0 in CThread::staticThread (data=0x2df5c88) at Thread.cpp:131
#23 0x76bb1f78 in start_thread () from /usr/lib/libpthread.so.0
#24 0x75cdaa80 in ?? () from /usr/lib/libc.so.6

comment:3 Changed at 2016-06-26T18:56:49+01:00 by asavah

This issue happens only on arm if Kodi was built with gcc > 5.1.x with --enable-optimizations.

Still happens on master https://github.com/xbmc/xbmc/commit/b101751eb0186377f366f2e4673e853865472641

Still happens with gcc-5.4.0

A little bit more info here http://forum.kodi.tv/showthread.php?tid=269814&pid=2364829#pid2364829

And here https://archlinuxarm.org/forum/viewtopic.php?f=9&t=9600&start=0

comment:4 Changed at 2018-05-09T13:41:16+01:00 by Rechi

Does this still happen with newer Kodi and compiler versions?

comment:5 Changed at 2019-09-18T07:14:41+01:00 by k4fros

I can confirm the issue is still present when using gcc-5.5.0 to compile Kodi 18.4 (release) on RPi3 B and is resolved using the patch/hack provided in the Kodi forum url mentioned in comment:3. The segfault looks like:

(gdb) bt
#0  0x7567dbb0 in std::_Rb_tree_increment(std::_Rb_tree_node_base const*) () from /usr/lib/libstdc++.so.6
#1  0x0093624c in std::_Rb_tree_iterator<std::pair<Field const, CVariant> >::operator++ (this=<synthetic pointer>) at /usr/include/c++/5.5.0/bits/stl_tree.h:205
#2  std::_Rb_tree<Field, std::pair<Field const, CVariant>, std::_Select1st<std::pair<Field const, CVariant> >, std::less<Field>, std::allocator<std::pair<Field const, CVariant> > >::_M_get_insert_hint_unique_pos ([email protected]: 1366193490, __position=..., this=0x696fd9f8) at /usr/include/c++/5.5.0/bits/stl_tree.h:1969
#3  std::_Rb_tree<Field, std::pair<Field const, CVariant>, std::_Select1st<std::pair<Field const, CVariant> >, std::less<Field>, std::allocator<std::pair<Field const, CVariant> > >::_M_emplace_hint_unique<const std::piecewise_construct_t&, std::tuple<Field&&>, std::tuple<> >(std::_Rb_tree<Field, std::pair<Field const, CVariant>, std::_Select1st<std::pair<Field const, CVariant> >, std::less<Field>, std::allocator<std::pair<Field const, CVariant> > >::const_iterator) ([email protected]=0x696fd9f8, [email protected]=...) at /usr/include/c++/5.5.0/bits/stl_tree.h:2203
#4  0x0099b9f0 in std::map<Field, CVariant, std::less<Field>, std::allocator<std::pair<Field const, CVariant> > >::operator[] (
    __k=<unknown type in /usr/lib/kodi/kodi-rbpi, CU 0x0, DIE 0x3f335>, this=0x696fd9f8) at /usr/include/c++/5.5.0/bits/stl_map.h:503
#5  DatabaseUtils::GetDatabaseResults (mediaType=..., fields=..., dataset=..., results=...) at /tmp2/xbmc-18.4/xbmc/utils/DatabaseUtils.cpp:368
#6  0x009f8804 in SortUtils::SortFromDataset (sortDescription=..., mediaType=..., dataset=..., results=...) at /tmp2/xbmc-18.4/xbmc/utils/SortUtils.cpp:795
#7  0x008e6a38 in CVideoDatabase::GetMoviesByWhere ([email protected]=0x696fe678, strBaseDir=..., filter=..., items=..., sortDescription=..., getDetails=0)
    at /tmp2/xbmc-18.4/xbmc/video/VideoDatabase.cpp:7151
#8  0x008e7998 in CVideoDatabase::GetRecentlyAddedMoviesNav (this=0x696fe678, strBaseDir=..., items=..., limit=<optimized out>, getDetails=0)
    at /tmp2/xbmc-18.4/xbmc/video/VideoDatabase.cpp:7465
#9  0x009d8d74 in CRecentlyAddedJob::UpdateVideo () at /tmp2/xbmc-18.4/xbmc/utils/RecentlyAddedJob.cpp:52
#10 0x009e13e4 in CRecentlyAddedJob::DoWork (this=0x4cc6d90) at /tmp2/xbmc-18.4/xbmc/utils/RecentlyAddedJob.cpp:374
#11 0x009bfd44 in CJobWorker::Process (this=0x6fa903e8) at /tmp2/xbmc-18.4/xbmc/utils/JobManager.cpp:55
#12 0x00a2ff40 in CThread::Action (this=0x6fa903e8) at /tmp2/xbmc-18.4/xbmc/threads/Thread.cpp:208
#13 0x00a3177c in CThread::staticThread (data=0x6fa903e8) at /tmp2/xbmc-18.4/xbmc/threads/Thread.cpp:116
#14 0x76f09678 in start_thread () from /lib/libpthread.so.0
Backtrace stopped: Cannot access memory at address 0x31203428
(gdb) frame 4
#4  0x0099b9f0 in std::map<Field, CVariant, std::less<Field>, std::allocator<std::pair<Field const, CVariant> > >::operator[] (
    __k=<unknown type in /usr/lib/kodi/kodi-rbpi, CU 0x0, DIE 0x3f335>, this=0x696fd9f8) at /usr/include/c++/5.5.0/bits/stl_map.h:503
503               __i = _M_t._M_emplace_hint_unique(__i, std::piecewise_construct,
(gdb) 

P.S1: The OS is Slackware ARM 14.2 and the generated binary 32bit, softfp.

P.S2: Was initially reported here https://forum.kodi.tv/showthread.php?tid=347252

Note: See TracTickets for help on using tickets.