Skip to content

segfault when using shout-python inside a thread

Recently a machine was upgraded/reinstalled from an older Ubuntu version to the most recent Debian version. Since then, I get a segfault in an application I wrote which sends data to an icecast daemon.

After some searching, I focused it down to threading. As soon as I call shout.send from inside a thread, I get a segfault. Below is a minimal piece of code which reproduces the error.

The error occurs on the second-last line (icy_handle.send(chunk))

I am running:

  • Python 2.7
  • shout-python==0.2.1
  • Debian 8.0
  • Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt2-1 (2014-12-08) x86_64 GNU/Linux

I am honestly a bit stumped. After roughly 4 hours of hit-and-miss I am out of ideas. I have not yet tried to set up an old machine representing the old Ubuntu environment. I also don’t remember the exact Ubuntu release. I think it was 12.04 but I am not sure. But I do know that it was running on that system. By the way: there were no hardware changes!

Any ideas?

The example code:

from threading import Thread

import shout

class Player(Thread):

    def __init__(self, filename, *args, **kwargs):
        super(Player, self).__init__(*args, **kwargs)
        self.filename = filename

    def run(self):
        icy_handle = shout.Shout()
        icy_handle.format = 'mp3'
        icy_handle.audio_info = {
            "bitrate": str(128),
            "samplerate": str(44100),
            "channels": str(1)}
        icy_handle.user = "source" = "test stream"
        icy_handle.url = ""
        icy_handle.password = "password123"
        icy_handle.mount = "/test.mp3"
        icy_handle.port = 8000

        chunk_size = 1024
        with open(self.filename, 'rb') as afile:
            chunk =
            while chunk:
                chunk =

if __name__ == "__main__":
    import sys

    if len(sys.argv) < 2:
        print """
        USAGE: %s <filename>
        """ % sys.argv[0]

    p = Player(sys.argv[1])



I can reproduce your problem with 0.2.1, but not with trunk. Please try:

 svn co

I’m pretty sure that this is the relevant fix:

We should release a new version. Let me get right on to that. (JFTR, this will involve me migrating the repository from SVN to git, so the above URL becomes invalid outside of this particular scope)

User contributions licensed under: CC BY-SA
1 People found this is helpful