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

Sporadic crash when during on my TV/Receiver due to double close() on the same fd in ActiveAE #16258

yasij opened this issue Jun 10, 2019 · 5 comments


Copy link

commented Jun 10, 2019

Bug report

Describe the bug

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

Kodi crashes sporadically when I turn on my TV and receiver since I upgraded to Ubuntu 19.04. There is a double close somewhere on the ActiveAE thread which is racing against the PeripBusUSBUdev. libudev has an assert when close returns EBADF. When I turn the TV on, it triggers udev_enumerate_scan_devices. This has been difficult to debug due to the sporadic nature of the race condition. I've straced kodi-x11 with close() calls, but if I add openat to the list, it disturbs the timing enough that I haven't been able to reproduce with that strace attached. It happens at least 50% of the time turning my TV on with no strace attached.

Expected Behavior

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

Kodi should not crash sporadically when turning on my TV.

Actual Behavior

Kodi crashes sporadically when turning on my TV.

Possible Fix

To Reproduce

Steps to reproduce the behavior:

  1. Boot machine with auto login to kodi. I'm using ALSA HDMI audio. The EDID is fixed.
  2. Turn my TV on. This triggers the receiver on via CEC.
  3. Kodi crashes.


The debuglog can be found here:
(Debugging is not on for this log because it disturbs the timing enough to mess with the race condition, and makes it hard to reproduce):

Stack strace from the core dump, it asserts inside libudev due to the double close on the other thread:
List of thread names for the tids:
Tail of the an strace showing the double close on the ActiveAE thread:


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

  • Linux

  • OSX

  • Raspberry-Pi

  • Windows

  • Windows UWP

  • Operating system version/name: Ubuntu 19.04

  • Kodi version: 18.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.


This comment has been minimized.

Copy link
Contributor Author

commented Jun 16, 2019

I did an strace with open, openat, close, creat and ioctl to try to better see what's going on. For the ActiveAE thread: The openat is on /dev/snd/controlC0. There is a double close of that file descriptor later on the thread. There must be a bad call to snd_ctl_close somewhere. I'll try to get a debug build of Kodi to trace those calls.


This comment has been minimized.

Copy link
Contributor Author

commented Jun 19, 2019

I finally had time to debug this more. It's a bug in jack2. I'm not even using jack on my system. However, with alsa-plugins >= 1.1.7, the ALSA to JACK plugin layer is enabled by default. Ubuntu 19.04 ships with alsa-plugins 1.1.8. Ubuntu 18.10 had alsa-plugins 1.1.6 which explains the behavior change. I'll send a patch to jack2.

@yasij yasij closed this Jun 19, 2019


This comment has been minimized.

Copy link

commented Jun 19, 2019

Could you summarize the issue with jack in more detail here? Perhaps there is something in kodi we can improve.


This comment has been minimized.

Copy link
Contributor Author

commented Jun 19, 2019

Fix merged in jack: jackaudio/jack2@dad4b57

Here are the stack traces for the two closes in libjack, and the addr2line decoded line numbers:

Kodi is calling EnumerateDevice over the list of ALSA sinks, and then TryDevice is opening each of them. For the jack plugin that Ubuntu 19.04 enables by default, that tries to open jack. However, libjack has a double close when it fails to connect to jackd because it closes the socket on error, and then closes it again in the cleanup code. I'm not running jackd. I don't even have it installed. That 2nd close races against the udev enumerator in kodi to cause the sporadic crash.

I think the only real workaround from the kodi side would be to ignore the ALSA jack plugin unless a user explicitly wants it.


This comment has been minimized.

Copy link

commented Jun 19, 2019

Thanks much. I think an Ubuntu Bugreport should be preferred then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.