I ran into the same issue.

Here's what appears to be happening:
1. ogg123 has a latent bug in how it handles a pthread mutex-- it always tries 
to unlock that mutex before exiting, even if the mutex is unlocked already. 
glibc on older CPUs tolerates this, which is why nobody has noticed until now.
2. glibc has implemented lock elision for CPUs that have working TSX 
(transactional memory) instructions.  When pthreads uses this lock elision 
code, unlocking an unlocked mutex segfaults.
3. If you have a new enough CPU that TSX instructions are usable (some CPUs 
have them disabled due to hardware bugs), ogg123 will segfault after it's done 
playing the file.  The segfault will always happen in  __lll_unlock_elision().

The vorbis-tools code hasn't changed in ages, so it's likely that this
happens on every distro shipping a modern glibc with lock elision
enabled.

I have some sample code here to demonstrate the glibc behavior on
different CPUs: https://codeandbitters.com/2016/04/18/fun-with-lock-
elision/

If you want a workaround for ogg123, this change seems to work for me:

--- a/ogg123/status.c
+++ b/ogg123/status.c
@@ -339,6 +339,7 @@ void status_deinit ()
 
 void status_reset_output_lock ()
 {
+  pthread_mutex_trylock(&output_lock);
   pthread_mutex_unlock(&output_lock);
 }

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1334204

Title:
  ogg123 crashes after playing sound file

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/vorbis-tools/+bug/1334204/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to