Frank Lazzarini
2014-Jul-18 19:33 UTC
[Icecast-dev] python-shout 0.2.1 with icecast 2.4.0 segfaults
Hi there, I am trying to use python-shout 0.2.1 to broadcast to a icecast 2.4.0 server, which result in a segmentation fault and I can't understand why. Is anyone else experiencing this problem? Here is the config that I use with icecast 2.4.0. <icecast> <limits> <clients>100</clients> <sources>2</sources> <threadpool>5</threadpool> <queue-size>524288</queue-size> <client-timeout>30</client-timeout> <header-timeout>15</header-timeout> <source-timeout>10</source-timeout> <burst-on-connect>1</burst-on-connect> <burst-size>65535</burst-size> </limits> <authentication> <source-password>passwood</source-password> <relay-password>passwood</relay-password> <admin-user>admin</admin-user> <admin-password>passwood</admin-password> </authentication> <hostname>thinkpad</hostname> <listen-socket> <port>8000</port> </listen-socket> <mount> <mount-name>/jukebox.ogg</mount-name> <username>source</username> <password>passwood</password> <max-listeners>10</max-listeners> <burst-size>>65536</burst-size> <hidden>1</hidden> <no-yp>1</no-yp> </mount> <fileserve>1</fileserve> <paths> <basedir>/usr/share/icecast2</basedir> <logdir>/var/log/icecast</logdir> <webroot>/usr/share/icecast2/web</webroot> <adminroot>/usr/share/icecast2/admin</adminroot> <alias source="/" dest="/status.xsl"/> </paths> <logging> <accesslog>access.log</accesslog> <errorlog>error.log</errorlog> <loglevel>4</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error --> <logsize>10000</logsize> <!-- Max size of a logfile --> </logging> <security> <chroot>0</chroot> </security> </icecast> # sudo -u nobody icecast -c /etc/icecast.xml I use the example.py which is included in python-shout package to test the broadcast, which result in the following. #!/usr/bin/env python # usage: ./example.py /path/to/file1 /path/to/file2 ... import shout import sys import string import time s = shout.Shout() print "Using libshout version %s" % shout.version() s.host = 'localhost' s.password = 'passwood' s.mount = "/jukebox.ogg" s.open() total = 0 st = time.time() for fa in sys.argv[1:]: print "opening file %s" % fa f = open(fa) s.set_metadata({'song': fa}) nbuf = f.read(4096) while 1: buf = nbuf nbuf = f.read(4096) total = total + len(buf) if len(buf) == 0: break s.send(buf) s.sync() f.close() et = time.time() br = total*0.008/(et-st) print "Sent %d bytes in %d seconds (%f kbps)" % (total, et-st, br) print s.close() # ./env/bin/python example.py test.mp3 Using libshout version 2.3.1 opening file test.mp3 Segmentation fault -- *Frank Lazzarini* *Email:* flazzarini at gmail.com *Phone:* +352 621 314 430 *Blog:* http://www.gefoo.org *LinkedIn:* http://www.linkedin.com/pub/frank-lazzarini/1a/a30/112 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/icecast-dev/attachments/20140718/23dd4f14/attachment.htm
"Thomas B. Rücker"
2014-Jul-21 12:49 UTC
[Icecast-dev] python-shout 0.2.1 with icecast 2.4.0 segfaults
Hi, On 07/18/2014 07:33 PM, Frank Lazzarini wrote:> Hi there, > > I am trying to use python-shout 0.2.1 to broadcast to a icecast 2.4.0 > server, which result in a segmentation fault and I can't understand > why. Is anyone else experiencing this problem?[?]> # ./env/bin/python example.py test.mp3 > Using libshout version 2.3.1 > opening file test.mp3 > Segmentation fault >As I'm not very well versed with those things it took me a bit, but I eventually dug out the problem. Something changed in python 2.5 (sic!), that broke the PyArg_ParseTuple call in shout.c (https://docs.python.org/2/c-api/arg.html#PyArg_ParseTuple). Below is a diff of a quick-fix that works for me. Before I commit that and roll a release, I'd like to hear though from someone well versed in those things if it's the right-thing? to do. ---------------------------------- Index: shout.c ==================================================================--- shout.c (revision 19173) +++ shout.c (working copy) @@ -19,6 +19,7 @@ * $Id$ */ +#define PY_SSIZE_T_CLEAN #include <Python.h> #include <shout/shout.h> ---------------------------------- Cheers Thomas
Frank Lazzarini
2014-Jul-21 12:56 UTC
[Icecast-dev] python-shout 0.2.1 with icecast 2.4.0 segfaults
Hi there, that really seems to be the issue here. I've quickly created a new sdist package for python-shout and installed it with the diff applied into my virtual environment and the broadcasting seems to work just fine again. So I can confirm this to solve the issue. Hopefully they accept Bug Fixes fast so everyone could profit from this. Thanks On Mon, Jul 21, 2014 at 2:49 PM, "Thomas B. R?cker" <thomas at ruecker.fi> wrote:> Hi, > > On 07/18/2014 07:33 PM, Frank Lazzarini wrote: > > Hi there, > > > > I am trying to use python-shout 0.2.1 to broadcast to a icecast 2.4.0 > > server, which result in a segmentation fault and I can't understand > > why. Is anyone else experiencing this problem? > [?] > > # ./env/bin/python example.py test.mp3 > > Using libshout version 2.3.1 > > opening file test.mp3 > > Segmentation fault > > > > As I'm not very well versed with those things it took me a bit, but I > eventually dug out the problem. Something changed in python 2.5 (sic!), > that broke the PyArg_ParseTuple call in shout.c > (https://docs.python.org/2/c-api/arg.html#PyArg_ParseTuple). > > Below is a diff of a quick-fix that works for me. Before I commit that > and roll a release, I'd like to hear though from someone well versed in > those things if it's the right-thing? to do. > > ---------------------------------- > Index: shout.c > ==================================================================> --- shout.c (revision 19173) > +++ shout.c (working copy) > @@ -19,6 +19,7 @@ > * $Id$ > */ > > +#define PY_SSIZE_T_CLEAN > #include <Python.h> > #include <shout/shout.h> > > ---------------------------------- > > > Cheers > > Thomas > _______________________________________________ > Icecast-dev mailing list > Icecast-dev at xiph.org > http://lists.xiph.org/mailman/listinfo/icecast-dev >-- *Frank Lazzarini* *Email:* flazzarini at gmail.com *Phone:* +352 621 314 430 *Blog:* http://www.gefoo.org *LinkedIn:* http://www.linkedin.com/pub/frank-lazzarini/1a/a30/112 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/icecast-dev/attachments/20140721/d50da57c/attachment.htm