Skip to content

ElementTree Python standard library experiences random SegFaults on Python 3.11 #22344

@jurialmunkey

Description

@jurialmunkey

Bug report

Describe the bug

Here is a clear and concise description of what the problem is:

Random SegFaults are experienced when using the Python ElementTree module to parse XML metadata via xml.etree.ElementTree.fromstring()

The problem appears to occur more frequently on ARM chipsets. On Intel x64 I've only been able to reproduce the issue twice via LibreELEC in a virtual machine. However I have a number of users with ARM devices who can reproduce the issue fairly reliably.

Through a lot of trial an error we've narrowed it down to the CAccelerator in _elementtree.c in Python. See comment here and issue thread in general: jurialmunkey/plugin.video.themoviedb.helper#948 (comment)

(NOTE: First issue in the above comment about offscreen ListItems has been addressed in TMDbHelper. It is the second issue in the comment related to ElementTree which persists)

Expected Behavior

Here is a clear and concise description of what was expected to happen:

ElementTree can be used to parse XML metadata without worrying about Kodi crashing from a SegFault

Actual Behavior

Kodi crashes randomly due to unexplained SegFaults in the _elementtree.c component

Possible Fix

To Reproduce

Steps to reproduce the behavior:

Difficult to provide an exact method to reproduce as crashes occur randomly. I don't own any ARM based devices so it is difficult for me to put together a simple test case. However, I do have a number of users who can provide testing as needed.

In TMDbHelper the steps are essentially:

  1. Install my skin Arctic Horizon 2 and TMDbHelper from my repository -- https://github.com/jurialmunkey/repository.jurialmunkey
  2. Get an API key from OMDb and enter it into TMDbHelper settings (OMDb API is the only API I use which has XML metadata).
  3. Restart Kodi to restart the service with the new setting.
  4. Browse movies for a while to get the service to attempt to retrieve ratings and it will eventually SegFault when parsing XML metadata.

I've seen other add-ons have similar issues so it isn't limited to TMDbHelper. For instance see this thread where a similar issue is encountered with a color switching addon for another skin: https://forum.libreelec.tv/thread/26400-is-it-possible-to-downgrade-python-version-without-use-a-old-image-libreelec/#wcf40

The commit for the addon mentioned in that thread is here and explicitly mentions Py3.11 crashes and a "fix" that comments out ElementTree: semool/script.arctic.zephyr.mod.autocolors@683ee3f

Debuglog

The debuglog can be found here:

Here's my debug logs from VirtualMachine running LibreELEC on x64 with backtrace showing SegFault in _elementtree
https://paste.kodi.tv/nalulopuco.kodi
https://paste.kodi.tv/ilonibiyub.kodi

See also this comment from one of my users on Ubuntu 22:
jurialmunkey/plugin.video.themoviedb.helper#948
https://paste.kodi.tv/giqavayuyu.kodi

And there's plenty of other users in that thread that can also provide detailed debugging

Screenshots

Here are some links or screenshots to help explain the problem:

Additional context or screenshots (if appropriate)

Here is some additional context or explanation that might help:

Your Environment

Used Operating system:

  • Android

  • iOS

  • tvOS

  • Linux

  • macOS

  • Windows

  • Windows UWP

  • Operating system version/name: LibreELEC 11 / Android / Ubuntu 22

  • Kodi version: Nexus RC 2

note: Once the issue is made we require you to update it with new information or Kodi versions should that be required.
Team Kodi will consider your problem report however, we will not make any promises the problem will be solved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution: Fixedissue was resolved by a code change

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions