Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PVR] Separate GUI from PVR core: remove CFileItem usage from core: step 1: directory listings. #16170

Merged
merged 1 commit into from May 19, 2019

Conversation

ksooo
Copy link
Member

@ksooo ksooo commented May 18, 2019

Fixes #16154

That issue reported one of many possible deadlock due to PVR core using CFileItem and CFileItemList. Those are GUI classes that might call at any time anywhere into PVR core, ignoring the PVR call dependency graph. Solution is to get rid of GUI classes in PVR core. This PR is the first step into that direction.

Example deadlock:

T28: CPVRChannelGroups => CPVRChannelGroup (which is fine, call dependency-wise)
T1: CPVRChannelGroup => CFileItem => CPVRChannelManager => CPVRChannelGroupsContainer (not okay, call dependency-wise. group must not call groups container!)

Thread 28 (Thread 0x7ff289d82700 (LWP 3471)):
#0  __pthread_mutex_lock_full (mutex=0x7ff28c0082a0) at ../nptl/pthread_mutex_lock.c:343
#1  0x0000000001589ac8 in PVR::CPVRChannelGroup::IsHidden() const ()
===> wants group mutex
#2  0x000000000159aca6 in PVR::CPVRChannelGroups::GetMembers(bool) const ()
===> has groups mutex
#3  0x0000000001821b43 in JSONRPC::CPVROperations::GetChannelGroups(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, JSONRPC::ITransportLayer*, JSONRPC::IClient*, CVariant const&, CVariant&) ()
#4  0x00000000017f5599 in JSONRPC::CJSONRPC::HandleMethodCall(CVariant const&, CVariant&, JSONRPC::ITransportLayer*, JSONRPC::IClient*) ()
#5  0x00000000017f663d in JSONRPC::CJSONRPC::MethodCall(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, JSONRPC::ITransportLayer*, JSONRPC::IClient*) ()
#6  0x0000000000901668 in CHTTPJsonRpcHandler::HandleRequest() ()
#7  0x00000000016b7b52 in CWebServer::HandleRequest(std::shared_ptr<IHTTPRequestHandler> const&) ()
#8  0x00000000016b5b3e in CWebServer::HandlePartialRequest(MHD_Connection*, CWebServer::ConnectionHandler*, HTTPRequest const&, char const*, unsigned long*, void**) ()
#9  0x00000000016b4444 in CWebServer::AnswerToConnection(void*, MHD_Connection*, char const*, char const*, char const*, char const*, unsigned long*, void**) ()
#10 0x00007ff32d530344 in ?? () from /usr/lib/x86_64-linux-gnu/libmicrohttpd.so.10
#11 0x00007ff32d5313fc in ?? () from /usr/lib/x86_64-linux-gnu/libmicrohttpd.so.10
#12 0x00007ff32d535289 in ?? () from /usr/lib/x86_64-linux-gnu/libmicrohttpd.so.10
#13 0x00007ff32ec1d6ba in start_thread (arg=0x7ff289d82700) at pthread_create.c:333
#14 0x00007ff327b8741d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 1 (Thread 0x7ff2cbfff700 (LWP 3576)):
#0  0x00007ff327ab5428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007ff327ab702a in __GI_abort () at abort.c:89
#2  0x00007ff327aadbd7 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x7ff32ec29030 "INTERNAL_SYSCALL_ERRNO (e, __err) != EDEADLK || (kind != PTHREAD_MUTEX_ERRORCHECK_NP && kind != PTHREAD_MUTEX_RECURSIVE_NP)", file=file@entry=0x7ff32ec28ff8 "../nptl/pthread_mutex_lock.c", line=line@entry=349, function=function@entry=0x7ff32ec29160 <__PRETTY_FUNCTION__.8794> "__pthread_mutex_lock_full") at assert.c:92
#3  0x00007ff327aadc82 in __GI___assert_fail (assertion=assertion@entry=0x7ff32ec29030 "INTERNAL_SYSCALL_ERRNO (e, __err) != EDEADLK || (kind != PTHREAD_MUTEX_ERRORCHECK_NP && kind != PTHREAD_MUTEX_RECURSIVE_NP)", file=file@entry=0x7ff32ec28ff8 "../nptl/pthread_mutex_lock.c", line=line@entry=349, function=function@entry=0x7ff32ec29160 <__PRETTY_FUNCTION__.8794> "__pthread_mutex_lock_full") at assert.c:101
#4  0x00007ff32ec1fc49 in __pthread_mutex_lock_full (mutex=0x44040b8) at ../nptl/pthread_mutex_lock.c:347
#5  0x0000000001598146 in PVR::CPVRChannelGroups::GetGroupAll() const ()
===> wants groups mutex
#6  0x00000000015a092f in PVR::CPVRChannelGroupsContainer::GetByUniqueID(int, int) const ()
===> groups container must not be called from group!!!
#7  0x00000000015c21b9 in 
PVR::CPVRManager::IsParentalLocked(std::shared_ptr<PVR::CPVREpgInfoTag> const&) const ()
#8  0x00000000013931ae in ?? ()
===> CFileItem calling back into PVR core
#9  0x00000000013941b3 in CFileItem::FillMusicInfoTag(std::shared_ptr<PVR::CPVRChannel> const&, std::shared_ptr<PVR::CPVREpgInfoTag> const&) ()
#10 0x00000000013a537a in CFileItem::CFileItem(std::shared_ptr<PVR::CPVRChannel> const&) ()
===> PVR core creating CFileItem !
#11 0x000000000158a68a in PVR::CPVRChannelGroup::GetMembers(CFileItemList&, PVR::CPVRChannelGroup::Include) const ()
===> has group mutex
#12 0x0000000001820acf in JSONRPC::CPVROperations::GetChannels(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, JSONRPC::ITransportLayer*, JSONRPC::IClient*, CVariant const&, CVariant&) ()
#13 0x00000000017f5599 in JSONRPC::CJSONRPC::HandleMethodCall(CVariant const&, CVariant&, JSONRPC::ITransportLayer*, JSONRPC::IClient*) ()
#14 0x00000000017f663d in JSONRPC::CJSONRPC::MethodCall(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, JSONRPC::ITransportLayer*, JSONRPC::IClient*) ()
#15 0x0000000000901668 in CHTTPJsonRpcHandler::HandleRequest() ()
#16 0x00000000016b7b52 in CWebServer::HandleRequest(std::shared_ptr<IHTTPRequestHandler> const&) ()
#17 0x00000000016b5b3e in CWebServer::HandlePartialRequest(MHD_Connection*, CWebServer::ConnectionHandler*, HTTPRequest const&, char const*, unsigned long*, void**) ()
#18 0x00000000016b4444 in CWebServer::AnswerToConnection(void*, MHD_Connection*, char const*, char const*, char const*, char const*, unsigned long*, void**) ()
#19 0x00007ff32d530344 in ?? () from /usr/lib/x86_64-linux-gnu/libmicrohttpd.so.10
#20 0x00007ff32d5313fc in ?? () from /usr/lib/x86_64-linux-gnu/libmicrohttpd.so.10
#21 0x00007ff32d535289 in ?? () from /usr/lib/x86_64-linux-gnu/libmicrohttpd.so.10
#22 0x00007ff32ec1d6ba in start_thread (arg=0x7ff2cbfff700) at pthread_create.c:333
#23 0x00007ff327b8741d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

@Jalle19 lots of code moved, but no functional changes. Good to go?

@ksooo ksooo added Type: Fix non-breaking change which fixes an issue Component: PVR Backport: Needed v19 Matrix labels May 18, 2019
@ksooo ksooo added this to the Matrix 19.0-alpha 1 milestone May 18, 2019
@ksooo ksooo requested a review from Jalle19 May 18, 2019 21:11
@ksooo
Copy link
Member Author

ksooo commented May 18, 2019

jenkins build this please

Copy link
Member

@Jalle19 Jalle19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to say if there are any problems, probably not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backport: Done Component: PVR Type: Fix non-breaking change which fixes an issue v19 Matrix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash Kodi 18.2 when loading PVR
2 participants