I installed Kodi long time ago in my Raspberry Pi 3 and it has been working without any issue for many months, but suddenly it has stopped working, and every time I try to run it using command "sudo kodi" it´s returning this error:

I assigned 256 Mb to GPU long time back (when it was working), and now I have tried increasing and decreasing it with the same result (actually I think after increasing the memory assigned to GPU the error takes longer to happen, around a minute instead of 30 seconds when gpu memory is 256 Mb). I have tried updating raspbian, reinstalling kodi, renaming folder ~/.kodi, removing the CEC peripherial from /usr/share/kodi/system/peripherals.xml, but nothing works and I am still getting the same error.

Please post your crash log into some site like pastebin:
Crash report available at /root/kodi_crashlog-20180509_212951.log
And it is not advisable to run Kodi as root, but that is not the cause of your problem, just an advice

It shows errors "Joystick Translator: Can't find button button" and "Window Translator: Can't find window musicfiles" but I am not sure if these errors are due to the permissions (as they are not present in the log when I run kodi with root privileges)

Whatch if you get any errors during reinstall. Then start Kodi with the user "Pi".

I have renamed .kodi folder and reinstalled kodi but it´s returning the same error, the only difference is this time the log doesn´t show any joystick error (before the log showed a joystick error when I executed kodi with pi user)

These are the steps I have followed to reinstall kodi, I don´t see any error during the installation:

I have activated the debug in advancedsettings.xml and the new log contains more information, but I still don´t see any error. This is the log from /home/pi/kodi_crashlog-20180512_180741.log: https://pastebin.com/GS3qADJZ

Yes, there isn't any error in your latest logs, that is really strange. Did you changed any hardware that you use with the Pi since the last time it worked ? Like power supply, microUSB cables, TV, etc ? Also did you installed/activated the open-source video/OpenGL drivers recently ? The only thing I can think off is some kind of library conflict in your system or filesystem corruption.

PS: Although there is any error about that, it seems to fail when starting python engine. Can you confirm if all is fine with your python libraries ?

I have some things connected to the raspberry (as a microphone, a thermometer, or a hard disk) but to ensure nothing connected to it was causing the issue I rebooted the raspberry with just the hdmi and the power connected, and the same error happened, so I assume it must be a software problem.

About the python libraries, other python scripts are working without issues, but how can I check if python libraries are fine?

That kind of hardware shouldn't interfere with Kodi, but the TV, specially it's CEC implementation can cause the crash. Can you try it with another TV ?
About python, Kodi depends on python2.7, many different packages, you have to check the depends section of "kodi" and "kodi-bin" packages. Can you please provide the output of the following, maybe we can figure it out by that:

Thank you for your help anyway, it looks like a really stubborn problem, I will try to connect the raspberry to a different TV as you mentioned before to see if the miracle happens (so far I have tried to open kodi with the TV off, but the result is the same).

I have the same problem after update && upgrade. No kodi, no Remmina, No VLC. It looks like something broken with the new GPU drivers or something else.
If I reinstall the image of OS back, everything is back to normal.
Double-checked this on two RPI 3.

I have the same problem after update && upgrade. No kodi, no Remmina, No VLC. It looks like something broken with the new GPU drivers or something else.
If I reinstall the image of OS back, everything is back to normal.
Double-checked this on two RPI 3.

There is no problem with latest stretch version and updated gpu drivers/kernel firmware after upgrading, at least on Kodi and desktop applications. I have tested this on multiple Pis.
I think your problem is something like a not good power supply and/or sdcard. If you don't have a a good power supply and sdcard, it can cause problems on updates, like never ending updates and filesystem corruption, I have noticed that on some occasions with some sdcards/power supplies.