Kodi Community Forum

Full Version: Need advice on kodi matrix not starting with "free(): invalid pointer"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am compiling a buildroot environment using their latest commits, which use matrix 19.1. When I try and start kodi it's immediately crashing with "free(): invalid pointer". There are no legacy files from an older version, as this is a fresh build (I know that can cause problems.)

Kodi (19.1 (19.1.0) Git:20210521-nogitfound). Platform: Linux ARM 32-bit
Kodi compiled 2021-05-21 by GCC 9.3.0 for Linux ARM 32-bit version 4.4.255 (263423)
Running on Pine64 Rock64 with Buildroot 2021.05-rc1, kernel: Linux ARM 64-bit version 4.4.258
FFmpeg version/source: 4.4-Kodi
Host CPU: ARMv8 Processor rev 4 (v8l), 4 cores available

Below is all the detail I have, would appreciate any tips as to where to look first!

When running "/usr/lib/kodi/kodi.bin --standalone --debug -fs --lircdev /var/run/lirc/lircd"
GDB backtrace:
https://dpaste.com/CTSLVWB4P

Kodi Log:
https://dpaste.com/D83BEK5US

Sometimes I also get: "munmap_chunk(): invalid pointer" instead, but that is random.

I've tried it with no parameters at all as well, with the same results.

Thanks in advance for any advice, GDB isn't really giving me much to go on.
If I had to guess I'd say that something (everything?) is wrong with mali blobs you are using, I'm not 100% certain tho.
Are you using kernel 4.4 from rockchip vendored tree? https://github.com/rockchip-linux/kernel is broken in too many ways.

I've had my fair share of dealing with Rock64 board and I was having lots of troubles with it until I fed the poor thing to my drawer and it remains there to this day.
I refuse to touch anything rockchip since then Smile 

Things you could try:

Ask around on vendor's forums - https://forum.pine64.org/
Try mainline kernel, AFAIK there should be at least half-decent support support for rock64 already.
Try building mesa with its lima driver instead of mali trash.
Take a look at what packages and patches LibreELEC people make use of and how they configure stuff for rock64 and friends https://github.com/LibreELEC/LibreELEC.t...s/Rockchip
Thank you *greatly* for the reply, and honestly that really is some awesome suggestions! However....

I can confirm using the exact same environment that kodi 18.9 runs perfectly, same libraries and everything. So it's absolutely something that's changed in matrix Sad

I actually maintain my own Rockchip linux kernel that contains all of the BSP stuff but a massive amount of extra backports, updates, and custom fixes... all of which work perfectly to provide 4k UHD @ 60fps playback using Kodi 18.9 on my Rock64.

I've tried compiling 19.1 "stock" without any patches at all, as well as with applicable patches from LibreElec. Sadly, same error.

I'm not quite ready to jump into mainline kernel yet, I'm waiting for the same level of UHD playback to be supported. I do totally agree lima / panfrost have a massively brighter future than the mali blobs though!

One update - as I've continued testing and tinkering, I was somehow able to get to the matrix splash screen exactly ONE time... but because I had removed all the addons for this test it crashed when it couldn't find the skins. Of course every test since has crashed lol

I'm continuing to test with slightly different compiler flags... adding "-g" for debug symbols results in some assembly compiler errors so cannot go that route Sad
I am also mid-way through compiling the popcornmix fork of matrix for gbm, so maybe that will give some different results.

Keep you all updated, but I really do welcome any and all ideas and suggestions.
FYI to anyone reading this...

"drmModeRmFB" removes the GBM framebuffer. Trying to delete it after calling that will cause a segfault when trying to free that already removed pointer.

You're welcome Smile Kodi matrix now booting just fine. Altho I'm testing the popcornmix fork at the moment, I expect the same issue is true for the stock version, as I was getting the same error.
@Mrfixit2001 try enabling debug logging via advancedsettings.xml https://kodi.wiki/view/Log_file/Advanced and post a link to it.
It could show some interesting details.
There indeed were many changes in gbm code in Matrix, it works pretty well on raspberry pi and intel hardware, both use mesa's implementation (different drivers ofcourse),
so there indeed is a possibility that something broke wrt to the implementation inside mali blobs.

Did your mali userspace drivers come with a libgbm.so (they used to *not* provide it) or you are using a wrapper of some kind?
libgbm is provided by rockchip libmali, along with libgles. Those libraries are just symlinks back to the libmali blob.

I'm recompiling your master commit from github now so that I can properly give you some feedback without running a kodi fork Smile
Update - pulling master was not a great idea lol 

This commit broke a LOT of stuff since 19.1

https://github.com/xbmc/xbmc/commit/ba42...9025e761fa

recompiling 19.1 now.
(2021-05-21, 23:32)Mrfixit2001 Wrote: [ -> ]This commit broke a LOT of stuff since 19.1

https://github.com/xbmc/xbmc/commit/ba42...9025e761fa

I'm running master with this commit on my homegrown OS as we speak , everything is fine here.
Another update:

I apologize, I was wrong about that commit being the issue, I was looking in the wrong place.

Matrix starts, but I cannot play any media - both master commit and 19.1 crash when selecting a file with: Could not get EGL function "eglQueryDmaBufFormatsEXT" - maybe a required extension is not supported?

popcornmix fork plays media fine. hmm

Here's my supported EGL extensions:
EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_EXT_image_dma_buf_import EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_gl_renderbuffer_image EGL_KHR_reusable_sync EGL_KHR_fence_sync EGL_KHR_lock_surface EGL_KHR_lock_surface2 EGL_EXT_create_context_robustness EGL_ANDROID_blob_cache EGL_KHR_create_context EGL_KHR_partial_update EGL_KHR_create_context_no_error

I'll figure it out and do some bisecting against the diffs between the two repos. In any event, my original issue is solved so with a bit more tinkering I should be in good shape. Thanks for the quick (and helpful) replies!
Not-so-well supported by their vendors ARM boards with blobs and half-broken kernel are a PITA.
Been there, done that.
I have a small collection of ARM SBCs and I can feel your pain.
Turns out I needed to change the videoplayer to use direct-to-plane in order to work properly Smile
I dropped in my custom patchset and I'm back at rockchip 4k uhd 60fps playback. 

You've been the most responsive out of any mod on this forum, and genuinely tried to help. I've seen others quick to dismiss questions like mine. Thanks for your efforts, I'm good to go!