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

Fix libamplayer.so/libamcodec.so issue #2

Merged
merged 4 commits into from
Nov 26, 2015

Conversation

Holzhaus
Copy link

This PR removes some unused code and fixes an issue on some (most?) linux distributions (e.g. OpenELEC, ArchLinuxARM). It occurs when libamplayer.so is not present, since these distros use libamcodec.so instead, which is included in the latest buildroot package (2015-01-20-4a5990f135) from Amlogic (See buildroot/package/multimedia/aml_libs/src/amcodec/Makefile, line 26).

Thus, users of these distros will eventually run into this issue:

ERROR: Unable to load libamplayer.so, reason: libamplayer.so: cannot
open shared object file: No such file or directory

This PR fixes that by checking if libamplayer.so can be loaded, and
if not, we'll try to use libamcodec.so instead.

The methods "h263vld" and "decodeble_h263()" from DllLibAmCodec are not
used anymore. The "h263_decodable" member from the am_private_t struct
is also obsolete now. Although the struct member "flv_flag" gets
assigned, is never read, so we remove it, too.
@@ -1427,6 +1371,10 @@ CAMLCodec::CAMLCodec() : CThread("CAMLCodec")
am_private = new am_private_t;
memset(am_private, 0, sizeof(am_private_t));
m_dll = new DllLibAmCodec;
if(!(m_dll->CanLoad() && m_dll->Load())) {
Copy link
Owner

Choose a reason for hiding this comment

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

CanLoad doesn't work on Android. Does it on Linux?

Also please follow formatting guidelines:

  • 2 spaces indent (for info, haven't seen an issue)
  • Opening bracket on own line

Copy link
Author

Choose a reason for hiding this comment

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

CanLoad doesn't work on Android. Does it on Linux?

We could just leave it out, since DllDynamic::Load() seems to return a boolean value to indicate if loading was successful. I think we could simply use that.

Also please follow formatting guidelines

  • 2 spaces indent (for info, haven't seen an issue)
  • Opening bracket on own line

I tried to match the formatting of the rest of the code in that file, but I took the wrong line as an example. ;-)

I fixed the issues and amended the commit to keep the history clean. I'll recompile and test, but since i'm compiling on the device itself, that will take a while.

{
CLog::Log(LOGDEBUG, "CAMLCodec::CAMLCodec libamplayer.so not found, trying libamcodec.so instead");
m_dll->SetFile("libamcodec.so");
}
m_dll->Load();
Copy link
Author

Choose a reason for hiding this comment

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

While this should work anyway (if the first Load() call was successful, the second one should return immediately), it looks kinda strange, and i'll move it into the if conditional.

@Holzhaus
Copy link
Author

Just recompiled and tested this version on my Amlogic S805/Meson8B SBC running ArchLinux ARM without libamplayer.so installed. It works as expected (i.e. it uses libamcodec.so if libamplayer.so is not installed).

Some Linux distibutions like OpenELEC and ArchLinuxARM ship
libamcodec.so instead of libamplayer.so, which is included in the latest
buildroot package (2015-01-20-4a5990f135) from Amlogic:

  http://openlinux.amlogic.com/wiki/index.php/Arm/Buildroot
  (buildroot/package/multimedia/aml_libs/src/amcodec/Makefile, line 26)

Thus, users of these distros will eventually run into this issue:

  ERROR: Unable to load libamplayer.so, reason: libamplayer.so: cannot
  open shared object file: No such file or directory

This commit fixes that by checking if libamplayer.so can be loaded, and
if not, we'll try to use libamcodec.so instead.
@Holzhaus
Copy link
Author

@koying Anything else that needs to be fixed before merging?

@koying
Copy link
Owner

koying commented Nov 26, 2015

No. I'll retest and merge

koying added a commit that referenced this pull request Nov 26, 2015
Fix libamplayer.so/libamcodec.so issue
@koying koying merged commit f147e88 into koying:master Nov 26, 2015
koying pushed a commit that referenced this pull request Apr 4, 2016
This patch is a backport of
xbmc@a81208e
to fix a segfault during playback of vaapi-accelerated mpeg2 content:

terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_S_construct null not valid
[New LWP 3743]

Program received signal SIGABRT, Aborted.
[Switching to LWP 3743]
0xb5664a9b in raise () from /lib/libc.so.0
(gdb) bt full
#0  0xb5664a9b in raise () from /lib/libc.so.0
No symbol table info available.
#1  0xb5660520 in abort () from /lib/libc.so.0
No symbol table info available.
#2  0xb56e6536 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/libstdc++.so.6
No symbol table info available.
#3  0xb56e4a1c in ?? () from /usr/lib/libstdc++.so.6
No symbol table info available.
#4  0xb56e4a80 in std::terminate() () from /usr/lib/libstdc++.so.6
No symbol table info available.
#5  0xb56e4cc9 in __cxa_throw () from /usr/lib/libstdc++.so.6
No symbol table info available.
#6  0xb5719d79 in std::__throw_logic_error(char const*) () from /usr/lib/libstdc++.so.6
No symbol table info available.
xbmc#7  0xb5722c41 in char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) () from /usr/lib/libstdc++.so.6
No symbol table info available.
xbmc#8  0xb5722cc7 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) () from /usr/lib/libstdc++.so.6
No symbol table info available.
xbmc#9  0x0848fea3 in CDVDVideoCodec::IsCodecDisabled (map=0x9130420 <g_vaapi_available>, size=5, id=AV_CODEC_ID_MPEG4)
    at DVDVideoCodec.cpp:75
        index = <optimized out>
xbmc#10 0x08499d04 in VAAPI::CDecoder::Open (this=0xd09e5e8, avctx=0xd6a2ec0, mainctx=0xd6a2ec0, fmt=AV_PIX_FMT_VAAPI_VLD,
    surfaces=6) at VAAPI.cpp:503
        gpuvendor = {static npos = <optimized out>,
          _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0xceb267c "intel open source technology center"}}
        profile = <optimized out>
xbmc#11 0x08491bda in CDVDVideoCodecFFmpeg::GetFormat (avctx=0xd6a2ec0, fmt=0x986d9c0) at DVDVideoCodecFFmpeg.cpp:143
        dec = 0xd09e5e8
        ctx = <optimized out>
        cur = 0x986d9c0
xbmc#12 0xb61c8ced in ?? () from /usr/lib/libavcodec.so.56
koying added a commit that referenced this pull request Apr 26, 2017
Report from Android O tesing on O:

From: <android-developer-preview-no-reply@google.com>
Date: Apr 19, 2017 21:20
Subject: Native crash when trying to open Kodi addon
To: <developers@kodi.tv>
Cc: <androidsupport@kodi.tv>

Hello,
In preparation for the upcoming release of Android O, we've been
rigorously testing popular applications on Google Play, including ”Kodi"
[org.xbmc.kodi].
During testing, we uncovered a bug specific to your application running
on the Android O Developer Preview. Here are the details:

Step(s) to Reproduce:

    Install “Kodi” application from Play store

    Launch the application

    Tap Add-Ons from the menu

Expected Result(s):

    App should not crash when tapping Add-Ons

Observed Result(s):

    App crashes when tapping Add-Ons

Possible Root Cause(s):

    It looks like Kodi is fetching an icon from PackageManager and
calling this method: icon.getBitmap(). This used to work in N and below
because all Icons were png, in which they could be cast to
BitmapDrawable. However, starting in the next OS, there is no guarantee
icon drawable objects can automatically convert to BitmapDrawable.
There is also no guarantee that all of BitmapDrawable's methods (such as
getBitmap) will be readily available.

Log:

java_vm_ext.cc:504] JNI DETECTED ERROR IN APPLICATION: mid == null
Revision: '0'
ABI: 'arm64'
pid: 9423, tid: 9469, name: Thread-5  >>> org.xbmc.kodi <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: 'java_vm_ext.cc:504] JNI DETECTED ERROR IN APPLICATION:
mid == null'
    x0   0000000000000000  x1   00000000000024fd  x2   0000000000000006
x3   0000000000000008
    x4   0000000000000114  x5   00000000000000ff  x6   0000000000000000
x7   0080808080808080
    x8   0000000000000083  x9   6cd9bf0d77661d2f  x10  0000000000000001
x11  0000000000000001
    x12  ffffffffffffffff  x13  0000000000000008  x14  ffffffffffffffff
x15  0030fcf94d051582
    x16  00000073abd6d300  x17  00000073abd0f3fc  x18  0000000000000020
x19  00000000000024cf
    x20  00000000000024fd  x21  0000007388714700  x22  0000000000000002
x23  00000000000000c1
    x24  00000000000009b7  x25  000000738c527600  x26  00000000000009b6
x27  00000073883fea20
    x28  0000000000000059  x29  00000073883fe8c0  x30  00000073abcc390c
    sp   00000073883fe880  pc   00000073abd0f404  pstate
0000000000000000
backtrace:
    #00 pc 0000000000069404  /system/lib64/libc.so (tgkill+8)
    #1 pc 000000000001d908  /system/lib64/libc.so (abort+80)
    #2 pc 00000000004325bc  /system/lib64/libart.so
(_ZN3art7Runtime5AbortEPKc+528)
    #3 pc 0000000000432ccc  /system/lib64/libart.so
(_ZN3art7Runtime7AborterEPKc+24)
    #4 pc 000000000051c578  /system/lib64/libart.so
(_ZN7android4base10LogMessageD1Ev+1016)
    #5 pc 00000000002d0920  /system/lib64/libart.so
(_ZN3art9JavaVMExt8JniAbortEPKcS2_+1716)
    #6 pc 00000000002d0bec  /system/lib64/libart.so
(_ZN3art9JavaVMExt9JniAbortFEPKcS2_z+176)
    xbmc#7 pc 000000000031482c  /system/lib64/libart.so
(_ZN3art3JNI17CallObjectMethodVEP7_JNIEnvP8_jobjectP10_jmethodIDSt9__va_list+1440)
    xbmc#8 pc 00000000013b8920  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so
(_ZN3jni7details20call_jhobject_methodEP7_JNIEnvP8_jobjectP10_jmethodIDz+148)
    xbmc#9 pc 000000000139f7a4  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so
(_ZN18CJNIBitmapDrawable9getBitmapEv+148)
    xbmc#10 pc 000000000130b8ac  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so
(_ZN5XFILE15CFileAndroidApp8ReadIconEPPhPjS3_+1008)
    xbmc#11 pc 0000000000cb33fc  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so
(_ZN12CBaseTexture12LoadFromFileERKSsjjbS1_+232)
    xbmc#12 pc 0000000000e8d6b0  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so (_ZN12CImageLoader6DoWorkEv+524)
    xbmc#13 pc 0000000000ad8ab8  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so (_ZN10CJobWorker7ProcessEv+68)
    xbmc#14 pc 0000000000b69184  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so (_ZN7CThread6ActionEv+44)
    xbmc#15 pc 0000000000b69418  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so
(_ZN7CThread12staticThreadEPv+148)
    xbmc#16 pc 0000000000065db4  /system/lib64/libc.so
(_ZL15__pthread_startPv+36)
    xbmc#17 pc 000000000001ec9c  /system/lib64/libc.so (__start_thread+68)

We wanted to let you know so you could take a look and address the
issue.

Please do not reply to this message. If you discover an issue with the
platform running Android O Dev Preview, please file a bug in our issue
tracker.

Thanks!

Android Support Team
koying added a commit that referenced this pull request May 28, 2017
Report from Android O tesing on O:

From: <android-developer-preview-no-reply@google.com>
Date: Apr 19, 2017 21:20
Subject: Native crash when trying to open Kodi addon
To: <developers@kodi.tv>
Cc: <androidsupport@kodi.tv>

Hello,
In preparation for the upcoming release of Android O, we've been
rigorously testing popular applications on Google Play, including ”Kodi"
[org.xbmc.kodi].
During testing, we uncovered a bug specific to your application running
on the Android O Developer Preview. Here are the details:

Step(s) to Reproduce:

    Install “Kodi” application from Play store

    Launch the application

    Tap Add-Ons from the menu

Expected Result(s):

    App should not crash when tapping Add-Ons

Observed Result(s):

    App crashes when tapping Add-Ons

Possible Root Cause(s):

    It looks like Kodi is fetching an icon from PackageManager and
calling this method: icon.getBitmap(). This used to work in N and below
because all Icons were png, in which they could be cast to
BitmapDrawable. However, starting in the next OS, there is no guarantee
icon drawable objects can automatically convert to BitmapDrawable.
There is also no guarantee that all of BitmapDrawable's methods (such as
getBitmap) will be readily available.

Log:

java_vm_ext.cc:504] JNI DETECTED ERROR IN APPLICATION: mid == null
Revision: '0'
ABI: 'arm64'
pid: 9423, tid: 9469, name: Thread-5  >>> org.xbmc.kodi <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: 'java_vm_ext.cc:504] JNI DETECTED ERROR IN APPLICATION:
mid == null'
    x0   0000000000000000  x1   00000000000024fd  x2   0000000000000006
x3   0000000000000008
    x4   0000000000000114  x5   00000000000000ff  x6   0000000000000000
x7   0080808080808080
    x8   0000000000000083  x9   6cd9bf0d77661d2f  x10  0000000000000001
x11  0000000000000001
    x12  ffffffffffffffff  x13  0000000000000008  x14  ffffffffffffffff
x15  0030fcf94d051582
    x16  00000073abd6d300  x17  00000073abd0f3fc  x18  0000000000000020
x19  00000000000024cf
    x20  00000000000024fd  x21  0000007388714700  x22  0000000000000002
x23  00000000000000c1
    x24  00000000000009b7  x25  000000738c527600  x26  00000000000009b6
x27  00000073883fea20
    x28  0000000000000059  x29  00000073883fe8c0  x30  00000073abcc390c
    sp   00000073883fe880  pc   00000073abd0f404  pstate
0000000000000000
backtrace:
    #00 pc 0000000000069404  /system/lib64/libc.so (tgkill+8)
    #1 pc 000000000001d908  /system/lib64/libc.so (abort+80)
    #2 pc 00000000004325bc  /system/lib64/libart.so
(_ZN3art7Runtime5AbortEPKc+528)
    #3 pc 0000000000432ccc  /system/lib64/libart.so
(_ZN3art7Runtime7AborterEPKc+24)
    #4 pc 000000000051c578  /system/lib64/libart.so
(_ZN7android4base10LogMessageD1Ev+1016)
    #5 pc 00000000002d0920  /system/lib64/libart.so
(_ZN3art9JavaVMExt8JniAbortEPKcS2_+1716)
    #6 pc 00000000002d0bec  /system/lib64/libart.so
(_ZN3art9JavaVMExt9JniAbortFEPKcS2_z+176)
    xbmc#7 pc 000000000031482c  /system/lib64/libart.so
(_ZN3art3JNI17CallObjectMethodVEP7_JNIEnvP8_jobjectP10_jmethodIDSt9__va_list+1440)
    xbmc#8 pc 00000000013b8920  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so
(_ZN3jni7details20call_jhobject_methodEP7_JNIEnvP8_jobjectP10_jmethodIDz+148)
    xbmc#9 pc 000000000139f7a4  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so
(_ZN18CJNIBitmapDrawable9getBitmapEv+148)
    xbmc#10 pc 000000000130b8ac  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so
(_ZN5XFILE15CFileAndroidApp8ReadIconEPPhPjS3_+1008)
    xbmc#11 pc 0000000000cb33fc  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so
(_ZN12CBaseTexture12LoadFromFileERKSsjjbS1_+232)
    xbmc#12 pc 0000000000e8d6b0  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so (_ZN12CImageLoader6DoWorkEv+524)
    xbmc#13 pc 0000000000ad8ab8  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so (_ZN10CJobWorker7ProcessEv+68)
    xbmc#14 pc 0000000000b69184  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so (_ZN7CThread6ActionEv+44)
    xbmc#15 pc 0000000000b69418  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so
(_ZN7CThread12staticThreadEPv+148)
    xbmc#16 pc 0000000000065db4  /system/lib64/libc.so
(_ZL15__pthread_startPv+36)
    xbmc#17 pc 000000000001ec9c  /system/lib64/libc.so (__start_thread+68)

We wanted to let you know so you could take a look and address the
issue.

Please do not reply to this message. If you discover an issue with the
platform running Android O Dev Preview, please file a bug in our issue
tracker.

Thanks!

Android Support Team
koying pushed a commit that referenced this pull request Jun 11, 2017
koying added a commit that referenced this pull request Jun 25, 2017
Report from Android O tesing on O:

From: <android-developer-preview-no-reply@google.com>
Date: Apr 19, 2017 21:20
Subject: Native crash when trying to open Kodi addon
To: <developers@kodi.tv>
Cc: <androidsupport@kodi.tv>

Hello,
In preparation for the upcoming release of Android O, we've been
rigorously testing popular applications on Google Play, including ”Kodi"
[org.xbmc.kodi].
During testing, we uncovered a bug specific to your application running
on the Android O Developer Preview. Here are the details:

Step(s) to Reproduce:

    Install “Kodi” application from Play store

    Launch the application

    Tap Add-Ons from the menu

Expected Result(s):

    App should not crash when tapping Add-Ons

Observed Result(s):

    App crashes when tapping Add-Ons

Possible Root Cause(s):

    It looks like Kodi is fetching an icon from PackageManager and
calling this method: icon.getBitmap(). This used to work in N and below
because all Icons were png, in which they could be cast to
BitmapDrawable. However, starting in the next OS, there is no guarantee
icon drawable objects can automatically convert to BitmapDrawable.
There is also no guarantee that all of BitmapDrawable's methods (such as
getBitmap) will be readily available.

Log:

java_vm_ext.cc:504] JNI DETECTED ERROR IN APPLICATION: mid == null
Revision: '0'
ABI: 'arm64'
pid: 9423, tid: 9469, name: Thread-5  >>> org.xbmc.kodi <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: 'java_vm_ext.cc:504] JNI DETECTED ERROR IN APPLICATION:
mid == null'
    x0   0000000000000000  x1   00000000000024fd  x2   0000000000000006
x3   0000000000000008
    x4   0000000000000114  x5   00000000000000ff  x6   0000000000000000
x7   0080808080808080
    x8   0000000000000083  x9   6cd9bf0d77661d2f  x10  0000000000000001
x11  0000000000000001
    x12  ffffffffffffffff  x13  0000000000000008  x14  ffffffffffffffff
x15  0030fcf94d051582
    x16  00000073abd6d300  x17  00000073abd0f3fc  x18  0000000000000020
x19  00000000000024cf
    x20  00000000000024fd  x21  0000007388714700  x22  0000000000000002
x23  00000000000000c1
    x24  00000000000009b7  x25  000000738c527600  x26  00000000000009b6
x27  00000073883fea20
    x28  0000000000000059  x29  00000073883fe8c0  x30  00000073abcc390c
    sp   00000073883fe880  pc   00000073abd0f404  pstate
0000000000000000
backtrace:
    #00 pc 0000000000069404  /system/lib64/libc.so (tgkill+8)
    #1 pc 000000000001d908  /system/lib64/libc.so (abort+80)
    #2 pc 00000000004325bc  /system/lib64/libart.so
(_ZN3art7Runtime5AbortEPKc+528)
    #3 pc 0000000000432ccc  /system/lib64/libart.so
(_ZN3art7Runtime7AborterEPKc+24)
    #4 pc 000000000051c578  /system/lib64/libart.so
(_ZN7android4base10LogMessageD1Ev+1016)
    #5 pc 00000000002d0920  /system/lib64/libart.so
(_ZN3art9JavaVMExt8JniAbortEPKcS2_+1716)
    #6 pc 00000000002d0bec  /system/lib64/libart.so
(_ZN3art9JavaVMExt9JniAbortFEPKcS2_z+176)
    xbmc#7 pc 000000000031482c  /system/lib64/libart.so
(_ZN3art3JNI17CallObjectMethodVEP7_JNIEnvP8_jobjectP10_jmethodIDSt9__va_list+1440)
    xbmc#8 pc 00000000013b8920  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so
(_ZN3jni7details20call_jhobject_methodEP7_JNIEnvP8_jobjectP10_jmethodIDz+148)
    xbmc#9 pc 000000000139f7a4  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so
(_ZN18CJNIBitmapDrawable9getBitmapEv+148)
    xbmc#10 pc 000000000130b8ac  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so
(_ZN5XFILE15CFileAndroidApp8ReadIconEPPhPjS3_+1008)
    xbmc#11 pc 0000000000cb33fc  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so
(_ZN12CBaseTexture12LoadFromFileERKSsjjbS1_+232)
    xbmc#12 pc 0000000000e8d6b0  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so (_ZN12CImageLoader6DoWorkEv+524)
    xbmc#13 pc 0000000000ad8ab8  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so (_ZN10CJobWorker7ProcessEv+68)
    xbmc#14 pc 0000000000b69184  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so (_ZN7CThread6ActionEv+44)
    xbmc#15 pc 0000000000b69418  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so
(_ZN7CThread12staticThreadEPv+148)
    xbmc#16 pc 0000000000065db4  /system/lib64/libc.so
(_ZL15__pthread_startPv+36)
    xbmc#17 pc 000000000001ec9c  /system/lib64/libc.so (__start_thread+68)

We wanted to let you know so you could take a look and address the
issue.

Please do not reply to this message. If you discover an issue with the
platform running Android O Dev Preview, please file a bug in our issue
tracker.

Thanks!

Android Support Team
koying added a commit that referenced this pull request Jun 29, 2017
Report from Android O tesing on O:

From: <android-developer-preview-no-reply@google.com>
Date: Apr 19, 2017 21:20
Subject: Native crash when trying to open Kodi addon
To: <developers@kodi.tv>
Cc: <androidsupport@kodi.tv>

Hello,
In preparation for the upcoming release of Android O, we've been
rigorously testing popular applications on Google Play, including ”Kodi"
[org.xbmc.kodi].
During testing, we uncovered a bug specific to your application running
on the Android O Developer Preview. Here are the details:

Step(s) to Reproduce:

    Install “Kodi” application from Play store

    Launch the application

    Tap Add-Ons from the menu

Expected Result(s):

    App should not crash when tapping Add-Ons

Observed Result(s):

    App crashes when tapping Add-Ons

Possible Root Cause(s):

    It looks like Kodi is fetching an icon from PackageManager and
calling this method: icon.getBitmap(). This used to work in N and below
because all Icons were png, in which they could be cast to
BitmapDrawable. However, starting in the next OS, there is no guarantee
icon drawable objects can automatically convert to BitmapDrawable.
There is also no guarantee that all of BitmapDrawable's methods (such as
getBitmap) will be readily available.

Log:

java_vm_ext.cc:504] JNI DETECTED ERROR IN APPLICATION: mid == null
Revision: '0'
ABI: 'arm64'
pid: 9423, tid: 9469, name: Thread-5  >>> org.xbmc.kodi <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: 'java_vm_ext.cc:504] JNI DETECTED ERROR IN APPLICATION:
mid == null'
    x0   0000000000000000  x1   00000000000024fd  x2   0000000000000006
x3   0000000000000008
    x4   0000000000000114  x5   00000000000000ff  x6   0000000000000000
x7   0080808080808080
    x8   0000000000000083  x9   6cd9bf0d77661d2f  x10  0000000000000001
x11  0000000000000001
    x12  ffffffffffffffff  x13  0000000000000008  x14  ffffffffffffffff
x15  0030fcf94d051582
    x16  00000073abd6d300  x17  00000073abd0f3fc  x18  0000000000000020
x19  00000000000024cf
    x20  00000000000024fd  x21  0000007388714700  x22  0000000000000002
x23  00000000000000c1
    x24  00000000000009b7  x25  000000738c527600  x26  00000000000009b6
x27  00000073883fea20
    x28  0000000000000059  x29  00000073883fe8c0  x30  00000073abcc390c
    sp   00000073883fe880  pc   00000073abd0f404  pstate
0000000000000000
backtrace:
    #00 pc 0000000000069404  /system/lib64/libc.so (tgkill+8)
    #1 pc 000000000001d908  /system/lib64/libc.so (abort+80)
    #2 pc 00000000004325bc  /system/lib64/libart.so
(_ZN3art7Runtime5AbortEPKc+528)
    #3 pc 0000000000432ccc  /system/lib64/libart.so
(_ZN3art7Runtime7AborterEPKc+24)
    #4 pc 000000000051c578  /system/lib64/libart.so
(_ZN7android4base10LogMessageD1Ev+1016)
    #5 pc 00000000002d0920  /system/lib64/libart.so
(_ZN3art9JavaVMExt8JniAbortEPKcS2_+1716)
    #6 pc 00000000002d0bec  /system/lib64/libart.so
(_ZN3art9JavaVMExt9JniAbortFEPKcS2_z+176)
    xbmc#7 pc 000000000031482c  /system/lib64/libart.so
(_ZN3art3JNI17CallObjectMethodVEP7_JNIEnvP8_jobjectP10_jmethodIDSt9__va_list+1440)
    xbmc#8 pc 00000000013b8920  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so
(_ZN3jni7details20call_jhobject_methodEP7_JNIEnvP8_jobjectP10_jmethodIDz+148)
    xbmc#9 pc 000000000139f7a4  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so
(_ZN18CJNIBitmapDrawable9getBitmapEv+148)
    xbmc#10 pc 000000000130b8ac  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so
(_ZN5XFILE15CFileAndroidApp8ReadIconEPPhPjS3_+1008)
    xbmc#11 pc 0000000000cb33fc  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so
(_ZN12CBaseTexture12LoadFromFileERKSsjjbS1_+232)
    xbmc#12 pc 0000000000e8d6b0  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so (_ZN12CImageLoader6DoWorkEv+524)
    xbmc#13 pc 0000000000ad8ab8  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so (_ZN10CJobWorker7ProcessEv+68)
    xbmc#14 pc 0000000000b69184  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so (_ZN7CThread6ActionEv+44)
    xbmc#15 pc 0000000000b69418  /data/app/org.xbmc.kodi-TYKIN-
5zBb80hcqOZMy_tw==/lib/arm64/libkodi.so
(_ZN7CThread12staticThreadEPv+148)
    xbmc#16 pc 0000000000065db4  /system/lib64/libc.so
(_ZL15__pthread_startPv+36)
    xbmc#17 pc 000000000001ec9c  /system/lib64/libc.so (__start_thread+68)

We wanted to let you know so you could take a look and address the
issue.

Please do not reply to this message. If you discover an issue with the
platform running Android O Dev Preview, please file a bug in our issue
tracker.

Thanks!

Android Support Team
koying pushed a commit that referenced this pull request Aug 12, 2017
koying added a commit that referenced this pull request Nov 27, 2017
Shouldn't happen, but it does, apparently...

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint:
'NVIDIA/foster_e/foster:6.0/MRA58K/324774_733.8518:user/release-keys'
Revision: '0'
ABI: 'arm'
pid: 20646, tid: 20677, name: Thread-3241  >>> com.semperpax.spmc16 <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: 'art/runtime/java_vm_ext.cc:410] JNI DETECTED ERROR IN
APPLICATION: java_object == null'
    r0 00000000  r1 000050c5  r2 00000006  r3 57a82978
    r4 57a82980  r5 57a82930  r6 00000001  r7 0000010c
    r8 4345a378  r9 42c7c800  sl 00000001  fp 00000001
    ip 00000006  sp 57a82428  lr 4060b339  pc 4060caf4  cpsr 40070010

backtrace:
    #00 pc 00041af4  /system/lib/libc.so (tgkill+12)
    #1 pc 00040335  /system/lib/libc.so (pthread_kill+32)
    #2 pc 0001ca6f  /system/lib/libc.so (raise+10)
    #3 pc 00019c21  /system/lib/libc.so (__libc_android_abort+34)
    #4 pc 000174e4  /system/lib/libc.so (abort+4)
    #5 pc 003338d1  /system/lib/libart.so (_ZN3art7Runtime5AbortEv+228)
    #6 pc 000f45fb  /system/lib/libart.so
(_ZN3art10LogMessageD2Ev+2226)
    xbmc#7 pc 0025aa27  /system/lib/libart.so
(_ZN3art9JavaVMExt8JniAbortEPKcS2_+1550)
    xbmc#8 pc 0025ae53  /system/lib/libart.so
(_ZN3art9JavaVMExt9JniAbortFEPKcS2_z+74)
    xbmc#9 pc 002802e3  /system/lib/libart.so
(_ZN3art3JNI14GetObjectClassEP7_JNIEnvP8_jobject+454)
    xbmc#10 pc 00c85418  /data/app/com.semperpax.spmc16-1/lib/arm/libspmc.so
(_ZNK19CJNIViewInputDevice7getNameEv+36)
    xbmc#11 pc 00c5f6b8  /data/app/com.semperpax.spmc16-1/lib/arm/libspmc.so
(_ZN17CWinEventsAndroid11MessagePumpEv+1064)
    xbmc#12 pc 00b09f84  /data/app/com.semperpax.spmc16-1/lib/arm/libspmc.so
(_ZN12CApplication9FrameMoveEbb+208)
    xbmc#13 pc 00b9729c  /data/app/com.semperpax.spmc16-1/lib/arm/libspmc.so
(_ZN16CXBApplicationEx3RunEv+196)
    xbmc#14 pc 00b9c4fc  /data/app/com.semperpax.spmc16-1/lib/arm/libspmc.so
(XBMC_Run+340)
    xbmc#15 pc 00508b78  /data/app/com.semperpax.spmc16-1/lib/arm/libspmc.so
(_ZN8CXBMCApp3runEv+44)
    xbmc#16 pc 0050aab8  /data/app/com.semperpax.spmc16-1/lib/arm/libspmc.so
(_Z10thread_runI8CXBMCAppXadL_ZNS0_3runEvEEEPvS1_+4)
    xbmc#17 pc 0003fc37  /system/lib/libc.so (_ZL15__pthread_startPv+30)
    xbmc#18 pc 0001a2a3  /system/lib/libc.so (__start_thread+6)
Rechi pushed a commit that referenced this pull request May 18, 2018
This was missing in commit 61dfb26

Found by GCC/ASAN:

 ASAN:DEADLYSIGNAL
 =================================================================
 ==3618==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x556a3a027be2 bp 0x7f517d4d2140 sp 0x7f517d4d2120 T41)
 ==3618==The signal is caused by a READ memory access.
 ==3618==Hint: address points to the zero page.
     #0 0x556a3a027be1 in VideoPicture::operator=(VideoPicture const&) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x22dfbe1)
     #1 0x556a3a026e24 in VideoPicture::SetParams(VideoPicture const&) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x22dee24)
     #2 0x556a3a061ebe in VAAPI::CVaapiDecodedPicture::operator=(VAAPI::CVaapiDecodedPicture const&) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x2319ebe)
     #3 0x556a3a061e75 in VAAPI::CVaapiDecodedPicture::CVaapiDecodedPicture(VAAPI::CVaapiDecodedPicture const&) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x2319e75)
     #4 0x556a3a0514d3 in VAAPI::COutput::Flush() (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x23094d3)
     #5 0x556a3a04eff4 in VAAPI::COutput::StateMachine(int, Actor::Protocol*, Actor::Message*) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x2306ff4)
     #6 0x556a3a050752 in VAAPI::COutput::Process() (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x2308752)
     xbmc#7 0x556a3a82ca0c in CThread::Action() (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x2ae4a0c)
     xbmc#8 0x556a3a82c0f8 in CThread::staticThread(void*) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x2ae40f8)
     xbmc#9 0x7f51a8e7f5a9 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x75a9)
     xbmc#10 0x7f51a0288cbe in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xf6cbe)
Rechi pushed a commit that referenced this pull request May 18, 2018
Fixes several nullptr dereference bugs which could occur after the
VNSI connection was closed by VDR, e.g.:

```
Program terminated with signal SIGSEGV, Segmentation fault.
#0  __GI___pthread_mutex_lock (mutex=0xf0) at ../nptl/pthread_mutex_lock.c:65
65	../nptl/pthread_mutex_lock.c: No such file or directory.
[Current thread is 1 (Thread 0x7fabcc406980 (LWP 686))]
(gdb) bt
#0  __GI___pthread_mutex_lock (mutex=0xf0) at ../nptl/pthread_mutex_lock.c:65
#1  0x000055afd0fd788c in (anonymous namespace)::CRecursiveMutex::lock (this=0xf0)
    at xbmc/threads/platform/RecursiveMutex.h:45
#2  0x000055afd0fd8978 in (anonymous namespace)::CountingLockable<XbmcThreads::CRecursiveMutex>::lock (this=0xf0)
    at xbmc/threads/Lockables.h:63
#3  0x000055afd0fd87c6 in (anonymous namespace)::UniqueLock<CCriticalSection>::UniqueLock (this=0x7ffd221f0450, lockable=...)
    at xbmc/threads/Lockables.h:132
#4  0x000055afd0ff3fed in CSingleLock::CSingleLock (this=0x7ffd221f0450, cs=...) at xbmc/threads/SingleLock.h:39
#5  0x000055afd1bc6147 in PVR::CPVRChannelGroup::GroupName (this=0x0) at xbmc/pvr/channels/PVRChannelGroup.cpp:1142
#6  0x000055afd1b31555 in PVR::CGUIWindowPVRBase::UpdateButtons (this=0x55afd6d030b0)
    at xbmc/pvr/windows/GUIWindowPVRBase.cpp:480
xbmc#7  0x000055afd1b39898 in PVR::CGUIWindowPVRRecordingsBase::UpdateButtons (this=0x55afd6d030b0)
    at xbmc/pvr/windows/GUIWindowPVRRecordings.cpp:187
xbmc#8  0x000055afd1459dc7 in CGUIMediaWindow::Update (this=0x55afd6d030b0, strDirectory=..., updateFilterPath=true)
    at xbmc/windows/GUIMediaWindow.cpp:905
```
Rechi pushed a commit that referenced this pull request May 18, 2018
Class `CBusyWaiter` derives from `CThread`, and its only instance
lives in the stack frame of `CGUIDialogBusy::Wait()`.

Commit cc8364a triggered an ancient
Kodi crash bug based on a misunderstanding how destructors work in
C++, introduced in commit 64427d4
(coincidentally by the same author).

Anyway, that commit cc8364a changed
how cancellation gets triggered, making it more likely.  And if that
cancellation happens, nobody takes care for stopping the CThread
properly; `~CThread()` calls `StopThread()`, but by then, the
`CBusyWaiter` instance has already been morphed back to its base class
`CThread`.  This however triggers the crash in the still-running
thread.

This class morphing while calling destructors is what makes the whole
`~CThread()` implementation wrong from the bottom: calling
`StopThread()` from the base class destructor can never ever work
properly, because it will crash the thread in any case.  And if no
thread were running anymore, the call would be useless.

All uses of `CThread` without additional calls to `StopThread()` are a
crash bug, but this commit fixes only the instance in class
`CBusyWaiter`, by adding another `StopThread()` call to its
destructor.

This is how the crash looks like:

```
Thread 1 (Thread 0x7ff1d37fe700 (LWP 1394)):
#0  __GI___pthread_mutex_lock (mutex=0x66657270747265d3) at ../nptl/pthread_mutex_lock.c:65
#1  0x0000562afcf3352c in (anonymous namespace)::CRecursiveMutex::lock (this=0x66657270747265d3) at xbmc/threads/platform/RecursiveMutex.h:45
#2  0x0000562afcf34618 in (anonymous namespace)::CountingLockable<XbmcThreads::CRecursiveMutex>::lock (this=0x66657270747265d3) at xbmc/threads/Lockables.h:63
#3  0x0000562afcf34466 in (anonymous namespace)::UniqueLock<CCriticalSection>::UniqueLock (this=0x7ff1d37fdb80, lockable=...) at xbmc/threads/Lockables.h:132
#4  0x0000562afcf3356f in CSingleLock::CSingleLock (this=0x7ff1d37fdb80, cs=...) at xbmc/threads/SingleLock.h:38
#5  0x0000562afd4ee7c7 in (anonymous namespace)::CEventGroup::Set (this=0x6665727074726563, child=0x7ffeca201060) at xbmc/threads/Event.h:127
#6  0x0000562afd4ee2db in CEvent::Set (this=0x7ffeca201060) at xbmc/threads/Event.cpp:70
xbmc#7  0x0000562afd4f16ff in CThread::staticThread (data=0x7ffeca200f80) at xbmc/threads/Thread.cpp:133
xbmc#8  0x00007ff20bd955aa in start_thread (arg=0x7ff1d37fe700) at pthread_create.c:463
xbmc#9  0x00007ff20321acbf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
```

And this is the thread which created the `CBusyWaiter` (at the time of
the crash it had already moved on):

```
Thread 19 (Thread 0x7ff20c191980 (LWP 1353)):
#0  0x00007ff209da1c83 in ?? () from /usr/lib/x86_64-linux-gnu/libsqlite3.so.0
#1  0x00007ff209d9c3c6 in ?? () from /usr/lib/x86_64-linux-gnu/libsqlite3.so.0
#2  0x00007ff209dcc0ab in ?? () from /usr/lib/x86_64-linux-gnu/libsqlite3.so.0
#3  0x00007ff209dd0c9e in ?? () from /usr/lib/x86_64-linux-gnu/libsqlite3.so.0
#4  0x00007ff209dd11fe in ?? () from /usr/lib/x86_64-linux-gnu/libsqlite3.so.0
#5  0x00007ff209dd1526 in sqlite3_prepare_v2 () from /usr/lib/x86_64-linux-gnu/libsqlite3.so.0
#6  0x0000562afd755a56 in (anonymous namespace)::SqliteDataset::query (this=0x562b03898080, query=...) at xbmc/dbwrappers/sqlitedataset.cpp:649
xbmc#7  0x0000562afd33a824 in CVideoDatabase::GetScraperForPath (this=0x562b02530f00, strPath=..., settings=..., foundDirectly=@0x7ffeca201b6f: false) at xbmc/video/VideoDatabase.cpp:7297
xbmc#8  0x0000562afd33b831 in CVideoDatabase::GetContentForPath (this=0x562b02530f00, strPath=...) at xbmc/video/VideoDatabase.cpp:7426
xbmc#9  0x0000562afd27dc6c in CGUIWindowVideoNav::LoadVideoInfo (items=..., database=..., allowReplaceLabels=true) at xbmc/video/windows/GUIWindowVideoNav.cpp:578
xbmc#10 0x0000562afd27db95 in CGUIWindowVideoNav::LoadVideoInfo (this=0x562b02530760, items=...) at xbmc/video/windows/GUIWindowVideoNav.cpp:564
xbmc#11 0x0000562afd27ce81 in CGUIWindowVideoNav::GetDirectory (this=0x562b02530760, strDirectory=..., items=...) at xbmc/video/windows/GUIWindowVideoNav.cpp:545
xbmc#12 0x0000562afd3b4e35 in CGUIMediaWindow::Update (this=0x562b02530760, strDirectory=..., updateFilterPath=true) at xbmc/windows/GUIMediaWindow.cpp:806
xbmc#13 0x0000562afd274a96 in CGUIWindowVideoBase::Update (this=0x562b02530760, strDirectory=..., updateFilterPath=true) at xbmc/video/windows/GUIWindowVideoBase.cpp:1247
xbmc#14 0x0000562afd27ae04 in CGUIWindowVideoNav::Update (this=0x562b02530760, strDirectory=..., updateFilterPath=true) at xbmc/video/windows/GUIWindowVideoNav.cpp:340
xbmc#15 0x0000562afd3b6e91 in CGUIMediaWindow::OnClick (this=0x562b02530760, iItem=2, player=...) at xbmc/windows/GUIMediaWindow.cpp:1072
xbmc#16 0x0000562afd270a66 in CGUIWindowVideoBase::OnClick (this=0x562b02530760, iItem=2, player=...) at xbmc/video/windows/GUIWindowVideoBase.cpp:609
xbmc#17 0x0000562afd283ec0 in CGUIWindowVideoNav::OnClick (this=0x562b02530760, iItem=2, player=...) at xbmc/video/windows/GUIWindowVideoNav.cpp:1205
xbmc#18 0x0000562afd3b7867 in CGUIMediaWindow::OnSelect (this=0x562b02530760, item=2) at xbmc/windows/GUIMediaWindow.cpp:1141
xbmc#19 0x0000562afd270c1b in CGUIWindowVideoBase::OnSelect (this=0x562b02530760, iItem=2) at xbmc/video/windows/GUIWindowVideoBase.cpp:627
xbmc#20 0x0000562afd3b1978 in CGUIMediaWindow::OnMessage (this=0x562b02530760, message=...) at xbmc/windows/GUIMediaWindow.cpp:319
xbmc#21 0x0000562afd26e169 in CGUIWindowVideoBase::OnMessage (this=0x562b02530760, message=...) at xbmc/video/windows/GUIWindowVideoBase.cpp:200
xbmc#22 0x0000562afd27a666 in CGUIWindowVideoNav::OnMessage (this=0x562b02530760, message=...) at xbmc/video/windows/GUIWindowVideoNav.cpp:254
xbmc#23 0x0000562afd61dbba in CGUIControl::SendWindowMessage (this=0x562b03547780, message=...) at xbmc/guilib/GUIControl.cpp:316
xbmc#24 0x0000562afd60ebaa in CGUIBaseContainer::OnClick (this=0x562b03547780, actionID=7) at xbmc/guilib/GUIBaseContainer.cpp:793
xbmc#25 0x0000562afd60cce7 in CGUIBaseContainer::OnAction (this=0x562b03547780, action=...) at xbmc/guilib/GUIBaseContainer.cpp:407
xbmc#26 0x0000562afd64570b in CGUIFixedListContainer::OnAction (this=0x562b03547780, action=...) at xbmc/guilib/GUIFixedListContainer.cpp:81
xbmc#27 0x0000562afd6a69fc in CGUIWindow::OnAction (this=0x562b02530760, action=...) at xbmc/guilib/GUIWindow.cpp:435
xbmc#28 0x0000562afd3b0d43 in CGUIMediaWindow::OnAction (this=0x562b02530760, action=...) at xbmc/windows/GUIMediaWindow.cpp:202
xbmc#29 0x0000562afd26dcb7 in CGUIWindowVideoBase::OnAction (this=0x562b02530760, action=...) at xbmc/video/windows/GUIWindowVideoBase.cpp:111
xbmc#30 0x0000562afd2797a0 in CGUIWindowVideoNav::OnAction (this=0x562b02530760, action=...) at xbmc/video/windows/GUIWindowVideoNav.cpp:105
xbmc#31 0x0000562afd6b3c14 in CGUIWindowManager::HandleAction (this=0x562b01d17c60, action=...) at xbmc/guilib/GUIWindowManager.cpp:1100
xbmc#32 0x0000562afd6b39ce in CGUIWindowManager::OnAction (this=0x562b01d17c60, action=...) at xbmc/guilib/GUIWindowManager.cpp:1050
xbmc#33 0x0000562afd8e1888 in CApplication::OnAction (this=0x562b01a4d5d0, action=...) at xbmc/Application.cpp:1924
xbmc#34 0x0000562afd5b729a in CInputManager::ExecuteInputAction (this=0x562b01bb8680, action=...) at xbmc/input/InputManager.cpp:704
xbmc#35 0x0000562afd5b6c86 in CInputManager::HandleKey (this=0x562b01bb8680, key=...) at xbmc/input/InputManager.cpp:644
xbmc#36 0x0000562afd5b5ed8 in CInputManager::OnKey (this=0x562b01bb8680, key=...) at xbmc/input/InputManager.cpp:483
xbmc#37 0x0000562afd5b5be6 in CInputManager::OnEvent (this=0x562b01bb8680, newEvent=...) at xbmc/input/InputManager.cpp:442
xbmc#38 0x0000562afd8d8aaf in CApplication::HandlePortEvents (this=0x562b01a4d5d0) at xbmc/Application.cpp:341
xbmc#39 0x0000562afd8e4fe6 in CApplication::FrameMove (this=0x562b01a4d5d0, processEvents=true, processGUI=true) at xbmc/Application.cpp:2647
xbmc#40 0x0000562afd9add56 in CXBApplicationEx::Run (this=0x562b01a4d5d0, params=...) at xbmc/XBApplicationEx.cpp:107
xbmc#41 0x0000562afd528974 in XBMC_Run (renderGUI=true, params=...) at xbmc/platform/xbmc.cpp:88
xbmc#42 0x0000562afcef1e72 in main (argc=4, argv=0x7ffeca2096e8) at xbmc/platform/posix/main.cpp:108
```
Rechi pushed a commit that referenced this pull request May 18, 2018
Probably many more attributes need to be protected, but this commit
aims to fix just this crash bug:

```
==2579==ERROR: AddressSanitizer: heap-use-after-free on address 0x611003c48200 at pc 0x555558929511 bp 0x7fffc7fc2710 sp 0x7fffc7fc2708
READ of size 8 at 0x611003c48200 thread T168 (PVRManager)
    #0 0x555558929510 in std::_Sp_counted_ptr<PVR::CPVRTimerType*, (__gnu_cxx::_Lock_policy)2>::_M_dispose() (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x33d5510)
    #1 0x555557165886 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x1c11886)
    #2 0x555557162ff9 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x1c0eff9)
    #3 0x555558913621 in std::__shared_ptr<PVR::CPVRTimerType, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x33bf621)
    #4 0x555558913663 in std::shared_ptr<PVR::CPVRTimerType>::~shared_ptr() (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x33bf663)
    #5 0x555558926430 in void std::_Destroy<std::shared_ptr<PVR::CPVRTimerType> >(std::shared_ptr<PVR::CPVRTimerType>*) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x33d2430)
    #6 0x555558924b2e in void std::_Destroy_aux<false>::__destroy<std::shared_ptr<PVR::CPVRTimerType>*>(std::shared_ptr<PVR::CPVRTimerType>*, std::shared_ptr<PVR::CPVRTimerType>*) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x33d0b2e)
    xbmc#7 0x5555589201a7 in void std::_Destroy<std::shared_ptr<PVR::CPVRTimerType>*>(std::shared_ptr<PVR::CPVRTimerType>*, std::shared_ptr<PVR::CPVRTimerType>*) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x33cc1a7)
    xbmc#8 0x55555891a094 in void std::_Destroy<std::shared_ptr<PVR::CPVRTimerType>*, std::shared_ptr<PVR::CPVRTimerType> >(std::shared_ptr<PVR::CPVRTimerType>*, std::shared_ptr<PVR::CPVRTimerType>*, std::allocator<std::shared_ptr<PVR::CPVRTimerType> >&) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x33c6094)
    xbmc#9 0x555558916a51 in std::vector<std::shared_ptr<PVR::CPVRTimerType>, std::allocator<std::shared_ptr<PVR::CPVRTimerType> > >::~vector() (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x33c2a51)
    xbmc#10 0x555558e3fe5b in PVR::CPVRTimerType::CreateFromAttributes(unsigned int, unsigned int, int) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x38ebe5b)
    xbmc#11 0x555558e0ac61 in PVR::CPVRTimerInfoTag::CPVRTimerInfoTag(bool) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x38b6c61)
    xbmc#12 0x555558e26831 in PVR::CPVRTimers::UpdateEntries(PVR::CPVRTimersContainer const&, std::vector<int, std::allocator<int> > const&) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x38d2831)
    xbmc#13 0x555558e24fa6 in PVR::CPVRTimers::Update() (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x38d0fa6)
    xbmc#14 0x555558e24b11 in PVR::CPVRTimers::Load() (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x38d0b11)
    xbmc#15 0x555558fd3397 in PVR::CPVRManager::LoadComponents(PVR::CPVRGUIProgressHandler*) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x3a7f397)
    xbmc#16 0x555558fd2362 in PVR::CPVRManager::Process() (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x3a7e362)
    xbmc#17 0x555558038fe0 in CThread::Action() (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x2ae4fe0)
    xbmc#18 0x5555580386cc in CThread::staticThread(void*) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x2ae46cc)
    xbmc#19 0x7ffff6c0e5a9 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x75a9)
    xbmc#20 0x7fffee013cbe in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xf6cbe)

0x611003c48200 is located 0 bytes inside of 216-byte region [0x611003c48200,0x611003c482d8)
freed by thread T166 (JobWorker) here:
    #0 0x7ffff6f01040 in operator delete(void*) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdc040)
    #1 0x555558e4071b in PVR::CPVRTimerType::~CPVRTimerType() (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x38ec71b)
    #2 0x555558929540 in std::_Sp_counted_ptr<PVR::CPVRTimerType*, (__gnu_cxx::_Lock_policy)2>::_M_dispose() (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x33d5540)
    #3 0x555557165886 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x1c11886)
    #4 0x55555738a63a in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::operator=(std::__shared_count<(__gnu_cxx::_Lock_policy)2> const&) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x1e3663a)
    #5 0x555558926844 in std::__shared_ptr<PVR::CPVRTimerType, (__gnu_cxx::_Lock_policy)2>::operator=(std::__shared_ptr<PVR::CPVRTimerType, (__gnu_cxx::_Lock_policy)2> const&) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x33d2844)
    #6 0x55555892686e in std::shared_ptr<PVR::CPVRTimerType>::operator=(std::shared_ptr<PVR::CPVRTimerType> const&) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x33d286e)
    xbmc#7 0x5555589268b8 in std::shared_ptr<PVR::CPVRTimerType>* std::__copy_move<false, false, std::random_access_iterator_tag>::__copy_m<std::shared_ptr<PVR::CPVRTimerType> const*, std::shared_ptr<PVR::CPVRTimerType>*>(std::shared_ptr<PVR::CPVRTimerType> const*, std::shared_ptr<PVR::CPVRTimerType> const*, std::shared_ptr<PVR::CPVRTimerType>*) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x33d28b8)
    xbmc#8 0x555558924ed2 in std::shared_ptr<PVR::CPVRTimerType>* std::__copy_move_a<false, std::shared_ptr<PVR::CPVRTimerType> const*, std::shared_ptr<PVR::CPVRTimerType>*>(std::shared_ptr<PVR::CPVRTimerType> const*, std::shared_ptr<PVR::CPVRTimerType> const*, std::shared_ptr<PVR::CPVRTimerType>*) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x33d0ed2)
    xbmc#9 0x55555892094e in __gnu_cxx::__normal_iterator<std::shared_ptr<PVR::CPVRTimerType>*, std::vector<std::shared_ptr<PVR::CPVRTimerType>, std::allocator<std::shared_ptr<PVR::CPVRTimerType> > > > std::__copy_move_a2<false, __gnu_cxx::__normal_iterator<std::shared_ptr<PVR::CPVRTimerType> const*, std::vector<std::shared_ptr<PVR::CPVRTimerType>, std::allocator<std::shared_ptr<PVR::CPVRTimerType> > > >, __gnu_cxx::__normal_iterator<std::shared_ptr<PVR::CPVRTimerType>*, std::vector<std::shared_ptr<PVR::CPVRTimerType>, std::allocator<std::shared_ptr<PVR::CPVRTimerType> > > > >(__gnu_cxx::__normal_iterator<std::shared_ptr<PVR::CPVRTimerType> const*, std::vector<std::shared_ptr<PVR::CPVRTimerType>, std::allocator<std::shared_ptr<PVR::CPVRTimerType> > > >, __gnu_cxx::__normal_iterator<std::shared_ptr<PVR::CPVRTimerType> const*, std::vector<std::shared_ptr<PVR::CPVRTimerType>, std::allocator<std::shared_ptr<PVR::CPVRTimerType> > > >, __gnu_cxx::__normal_iterator<std::shared_ptr<PVR::CPVRTimerType>*, std::vector<std::shared_ptr<PVR::CPVRTimerType>, std::allocator<std::shared_ptr<PVR::CPVRTimerType> > > >) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x33cc94e)
    xbmc#10 0x55555891b4ad in __gnu_cxx::__normal_iterator<std::shared_ptr<PVR::CPVRTimerType>*, std::vector<std::shared_ptr<PVR::CPVRTimerType>, std::allocator<std::shared_ptr<PVR::CPVRTimerType> > > > std::copy<__gnu_cxx::__normal_iterator<std::shared_ptr<PVR::CPVRTimerType> const*, std::vector<std::shared_ptr<PVR::CPVRTimerType>, std::allocator<std::shared_ptr<PVR::CPVRTimerType> > > >, __gnu_cxx::__normal_iterator<std::shared_ptr<PVR::CPVRTimerType>*, std::vector<std::shared_ptr<PVR::CPVRTimerType>, std::allocator<std::shared_ptr<PVR::CPVRTimerType> > > > >(__gnu_cxx::__normal_iterator<std::shared_ptr<PVR::CPVRTimerType> const*, std::vector<std::shared_ptr<PVR::CPVRTimerType>, std::allocator<std::shared_ptr<PVR::CPVRTimerType> > > >, __gnu_cxx::__normal_iterator<std::shared_ptr<PVR::CPVRTimerType> const*, std::vector<std::shared_ptr<PVR::CPVRTimerType>, std::allocator<std::shared_ptr<PVR::CPVRTimerType> > > >, __gnu_cxx::__normal_iterator<std::shared_ptr<PVR::CPVRTimerType>*, std::vector<std::shared_ptr<PVR::CPVRTimerType>, std::allocator<std::shared_ptr<PVR::CPVRTimerType> > > >) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x33c74ad)
    xbmc#11 0x55555891757f in std::vector<std::shared_ptr<PVR::CPVRTimerType>, std::allocator<std::shared_ptr<PVR::CPVRTimerType> > >::operator=(std::vector<std::shared_ptr<PVR::CPVRTimerType>, std::allocator<std::shared_ptr<PVR::CPVRTimerType> > > const&) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x33c357f)
    xbmc#12 0x5555588e314e in PVR::CPVRClient::GetAddonProperties() (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x338f14e)
    xbmc#13 0x555558f89eec in PVR::CPVRClients::ConnectionStateChange(PVR::CPVRClient*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, PVR_CONNECTION_STATE, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x3a35eec)
    xbmc#14 0x55555904915e in PVR::CPVRClientConnectionJob::DoWork() (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x3af515e)
    xbmc#15 0x555557ea8995 in CJobWorker::Process() (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x2954995)
    xbmc#16 0x555558038fe0 in CThread::Action() (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x2ae4fe0)
    xbmc#17 0x5555580386cc in CThread::staticThread(void*) (/usr/local/stow/kodi-asan/lib/kodi/kodi-x11+0x2ae46cc)
    xbmc#18 0x7ffff6c0e5a9 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x75a9)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants