Error with SfPlayer

22 views
Skip to first unread message

David Silverman

unread,
Aug 12, 2022, 7:33:54 PM8/12/22
to pyo-discuss
I am getting a SIGSEGV with the below code on a Raspberry Pi 3. The same code worked successfully on my Arch Linux laptop, with the difference that on the laptop I had to use jack as the audio server. On the Pi I am using portaudio

Please note that I can get the sound file to play on the pi with aplay just fine. Also, I was able to use pyo.Record no problems.

Python version is 3.9.2

OS version is Linux raspberrypi 5.15.56-v7+ #1575 SMP Fri Jul 22 20:28:11 BST 2022 armv7l GNU/Linux

  1. #!/usr/bin/env python3
  2. import sys
  3. sys.settrace
  4. import pyo

  5. s = pyo.Server().boot()
  6. s.start()
  7. looper = pyo.SfPlayer('/home/pi/guitar_audio/test_files/M1F1-int32-AFsp.aif')
  8. looper.out()
I ran with faulthandler and got this output:

Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Fatal Python error: Segmentation fault

Current thread 0x76f9e980 (most recent call first):
  File "/home/pi/.local/lib/python3.9/site-packages/pyo/lib/_core.py", line 208 in sndinfo
  File "/home/pi/.local/lib/python3.9/site-packages/pyo/lib/players.py", line 116 in __init__
  File "/home/pi/guitar_audio/test_files/sfplayer_test.py", line 8 in <module>


Then I ran with gdb and got the following backtrace:

Starting program: /usr/bin/python sfplayer_test.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
[New Thread 0x720e1440 (LWP 3163)]
[Thread 0x720e1440 (LWP 3163) exited]
[New Thread 0x71eff440 (LWP 3164)]

Thread 1 "python" received signal SIGSEGV, Segmentation fault.
0x76fba1dc in strlen () from /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so
#0  0x76fba1dc in strlen () at /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so
#1  0x0008ef0c in do_mkvalue (p_format=p_format@entry=0x7efff244, p_va=p_va@entry=0x7efff240, flags=flags@entry=1) at ../Python/modsupport.c:415
#2  0x0008f934 in do_mktuple (p_format=0x7efff244, p_format@entry=0x7efff23c, p_va=0x7efff240, p_va@entry=0x7efff238, endchar=endchar@entry=0 '\000', n=6, flags=<optimized out>,
    flags@entry=1) at ../Python/modsupport.c:264
#3  0x0008e9ec in va_build_value (format=<optimized out>, va=..., flags=1) at ../Python/modsupport.c:564
#4  0x0015c880 in _Py_BuildValue_SizeT (format=0x76453310 "lffiss") at ../Python/modsupport.c:530
#5  0x761ada28 in p_sndinfo () at /home/pi/.local/lib/python3.9/site-packages/pyo/_pyo.cpython-39-arm-linux-gnueabihf.so
#6  0x764ccfc8 in  ()



Alexandros

unread,
Aug 13, 2022, 3:15:04 AM8/13/22
to pyo-d...@googlegroups.com

From Pyo's backtrace it seems that the server is trying to connect to Jack, even though you don't want to use it. Did you try to initialize the server like this `s = pyo.Server(audio='portaudio').boot()`?

--
You received this message because you are subscribed to the Google Groups "pyo-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyo-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyo-discuss/afb84267-89c7-4caf-80fd-3a7b2e657ab7n%40googlegroups.com.

Alexandros

unread,
Aug 13, 2022, 3:16:37 AM8/13/22
to pyo-d...@googlegroups.com

Actually, I re-read the docs of Server() and saw that portaudio is the default, so my suggestion has probably no effect. Sorry for the noise.

On 13/8/22 02:33, 'David Silverman' via pyo-discuss wrote:

David Silverman

unread,
Aug 13, 2022, 7:21:35 AM8/13/22
to pyo-d...@googlegroups.com
My apologies, I should have noted that the errors mentioning Jack happen always for me, but it doesn’t cause any actual problem with pyo using portaudio. Those messages are warnings from Alsa. I can’t figure out how to get the warnings to stop. They are warnings only and have no effect. 

Alexandros you are correct that pyo is connecting to portaudio and the SIGSEGV error is coming from SfPlayer. Not from server.boot or start. 

From: pyo-d...@googlegroups.com <pyo-d...@googlegroups.com> on behalf of Alexandros <alexdry...@gmail.com>
Sent: Saturday, August 13, 2022 2:16:33 AM
To: pyo-d...@googlegroups.com <pyo-d...@googlegroups.com>
Subject: Re: [pyo-discuss] Error with SfPlayer
 
You received this message because you are subscribed to a topic in the Google Groups "pyo-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyo-discuss/bfDVr911g10/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyo-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyo-discuss/a0403d32-11be-536c-af84-a7c0fa3bab2b%40gmail.com.

David Silverman

unread,
Aug 23, 2022, 10:18:21 AM8/23/22
to pyo-discuss
I am trying to see if this error resolves with Jack on the raspberry pi. But I am having no luck compiling from source and then running. I have deleted my pip installed pyo and have installed using the linux build with jack script. But I am getting a "PYO built without Jack support" error message. I am not sure why. I am retracing my steps and trying again today. Any suggestions would be welcome.

David Silverman

unread,
Aug 23, 2022, 12:32:07 PM8/23/22
to pyo-discuss
I got Jack working. I deleted everything in /usr/local/lib/python3.9/dist-packages (which was only PYO) and then reran the install script. Now to test SfPlayer!

David Silverman

unread,
Aug 23, 2022, 1:00:05 PM8/23/22
to pyo-discuss
It doesn't work with Jack. I get the following errors. Note, all other pyo functionality is working correctly. I can run my guitar pedal amplifier script no problems. It is just SfPlayer.
Here is the code

  1   │ #!/usr/bin/env python3
   2   │ import sys
   3   │ sys.settrace
   4   │ import pyo
   5   │
   6   │ s = pyo.Server(audio='jack').boot()
   7   │ s.start()
   8   │ looper = pyo.SfPlayer('/home/pi/guitar_audio/test_files/M1F1-int32-AFsp.aif')
   9   │ looper.out()



and the errors

Cannot connect to server socket err = Connection refused

Cannot connect to server request channel
jackdmp 1.9.17
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2016 Grame.
Copyright 2016-2021 Filipe Coelho.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
Cannot connect to server socket err = Connection refused

Cannot connect to server request channel
audio_reservation_init
Acquire audio card Audio0
creating alsa driver ... hw:audioinjectorpi|hw:audioinjectorpi|1024|2|48000|0|0|nomon|swmeter|-|32bit
configuring for 48000Hz, period = 1024 frames (21.3 ms), buffer = 2 periods
ALSA: final selected sample format for capture: 32bit integer little-endian
ALSA: use 2 periods for capture
ALSA: final selected sample format for playback: 32bit integer little-endian
ALSA: use 2 periods for playback
Pyo warning: Jack server started.
Pyo warning: Sample rate set to Jack engine sample rate: 48000.
Pyo warning: Buffer size set to Jack engine buffer size: 1024.
JackEngine::XRun: client = pyo was not finished, state = Running
JackAudioDriver::ProcessGraphAsyncMaster: Process error
JackEngine::XRun: client = pyo was not finished, state = Triggered
JackAudioDriver::ProcessGraphAsyncMaster: Process error
JackEngine::XRun: client = pyo was not finished, state = Triggered
JackAudioDriver::ProcessGraphAsyncMaster: Process error
JackEngine::XRun: client = pyo was not finished, state = Triggered
JackAudioDriver::ProcessGraphAsyncMaster: Process error
JackEngine::XRun: client = pyo was not finished, state = Triggered
JackAudioDriver::ProcessGraphAsyncMaster: Process error
JackEngine::XRun: client = pyo was not finished, state = Triggered
JackAudioDriver::ProcessGraphAsyncMaster: Process error
fish: “python3 sfplayer_test.py” terminated by signal SIGSEGV (Address boundary error)
Cannot read socket fd = 14 err = Connection reset by peer
Could not read notification result
ClientNotify fails name = pyo notification = 18 val1 = 0 val2 = 0
Cannot write socket fd = 14 err = Broken pipe
CheckRes error
Could not write notification
ClientNotify fails name = pyo notification = 18 val1 = 1 val2 = 0
Unknown error...
terminate called after throwing an instance of 'Jack::JackTemporaryException'
  what():

David Silverman

unread,
Aug 23, 2022, 2:11:37 PM8/23/22
to pyo-discuss
I tried running with jack_control start before I ran my program, and I it still blew up, but I got more trace information from gdb. Hopefully this will help if anyone can try to solve!

Thread 1 "python" received signal SIGSEGV, Segmentation fault.
0x76fba1dc in strlen () from /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so
(gdb) backtrace full

#0  0x76fba1dc in strlen () at /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so
#1  0x0008ef0c in do_mkvalue
    (p_format=p_format@entry=0x7effec54, p_va=p_va@entry=0x7effec50, flags=flags@entry=1)
    at ../Python/modsupport.c:415
        str = 0x7effec54 "I\035Ev\344\354\377~\200\310\025"
        n = <optimized out>
#2  0x0008f934 in do_mktuple (p_format=0x7effec54,
    p_format@entry=0x7effec4c, p_va=0x7effec50,
    p_va@entry=0x7effec48, endchar=endchar@entry=0 '\000', n=6, flags=<optimized out>,
    flags@entry=1) at ../Python/modsupport.c:264
        w = <optimized out>
        i = 4

#3  0x0008e9ec in va_build_value (format=<optimized out>, va=..., flags=1)
    at ../Python/modsupport.c:564
        f = 0x76451d49 "s"
        n = <optimized out>
        lva = {__ap = 0x7effec90}
        retval = <optimized out>
#4  0x0015c880 in _Py_BuildValue_SizeT (format=0x76451d44 "lffiss")
    at ../Python/modsupport.c:530
        va = {__ap = 0x7effec74}
        retval = <optimized out>
#5  0x761d6a7c in p_sndinfo ()
    at /usr/local/lib/python3.9/dist-packages/pyo-1.0.4-py3.9-linux-armv7l.egg/pyo/_pyo.cpython-39-arm-linux-gnueabihf.so
#6  0x764d0ac8 in  ()

Olivier Bélanger

unread,
Aug 23, 2022, 2:45:16 PM8/23/22
to pyo-d...@googlegroups.com
Are you compiling pyo from sources? If so, can you try replacing the lowercase "l" with an uppercase "L" at line 422 of src/engine/pyomodule.c?

    return Py_BuildValue("Lffiss", info.frames, (float)info.frames / info.samplerate, (float)info.samplerate, info.channels, fileformat, sampletype);

Olivier


David Silverman

unread,
Aug 23, 2022, 3:37:22 PM8/23/22
to pyo-discuss
Hello Olivier! You and your code are amazing! And yes, compiling from source. I made the change in pyomodule.c and here's the error messages now. Please note that I am still able to run my main pyo program that doesn't us SfPlayer without problems. 

Starting program: /usr/bin/python sfplayer_test.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
[New Thread 0x72108440 (LWP 2024)]

Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
[Detaching after fork from child process 2025]

jackdmp 1.9.17
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2016 Grame.
Copyright 2016-2021 Filipe Coelho.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
audio_reservation_init
Acquire audio card Audio0
creating alsa driver ... hw:audioinjectorpi|hw:audioinjectorpi|1024|2|48000|0|0|nomon|swmeter|-|32bit
configuring for 48000Hz, period = 1024 frames (21.3 ms), buffer = 2 periods
ALSA: final selected sample format for capture: 32bit integer little-endian
ALSA: use 2 periods for capture
ALSA: final selected sample format for playback: 32bit integer little-endian
ALSA: use 2 periods for playback
[New Thread 0x72087440 (LWP 2031)]

Pyo warning: Jack server started.
Pyo warning: Sample rate set to Jack engine sample rate: 48000.
Pyo warning: Buffer size set to Jack engine buffer size: 1024.
[New Thread 0x6b89e440 (LWP 2032)]

JackEngine::XRun: client = pyo was not finished, state = Running
JackAudioDriver::ProcessGraphAsyncMaster: Process error
[Thread 0x6b89e440 (LWP 2032) exited]

JackEngine::XRun: client = pyo was not finished, state = Triggered
JackAudioDriver::ProcessGraphAsyncMaster: Process error
JackEngine::XRun: client = pyo was not finished, state = Triggered
JackAudioDriver::ProcessGraphAsyncMaster: Process error
JackEngine::XRun: client = pyo was not finished, state = Triggered
JackAudioDriver::ProcessGraphAsyncMaster: Process error
JackEngine::XRun: client = pyo was not finished, state = Triggered
JackAudioDriver::ProcessGraphAsyncMaster: Process error
JackEngine::XRun: client = pyo was not finished, state = Triggered
JackAudioDriver::ProcessGraphAsyncMaster: Process error
JackEngine::XRun: client = pyo was not finished, state = Triggered
JackAudioDriver::ProcessGraphAsyncMaster: Process error
JackEngine::XRun: client = pyo was not finished, state = Triggered
JackAudioDriver::ProcessGraphAsyncMaster: Process error
JackEngine::XRun: client = pyo was not finished, state = Triggered
JackAudioDriver::ProcessGraphAsyncMaster: Process error
JackEngine::XRun: client = pyo was not finished, state = Triggered
JackAudioDriver::ProcessGraphAsyncMaster: Process error

Thread 3 "python" received signal SIG32, Real-time event 32.
[Switching to Thread 0x72087440 (LWP 2031)]
__libc_read (nbytes=4, buf=0x72086cbc, fd=5) at ../sysdeps/unix/sysv/linux/read.c:26
26    ../sysdeps/unix/sysv/linux/read.c: No such file or directory.
(gdb) backtrace
#0  __libc_read (nbytes=4, buf=0x72086cbc, fd=5) at ../sysdeps/unix/sysv/linux/read.c:26
#1  __libc_read (fd=5, buf=0x72086cbc, nbytes=4) at ../sysdeps/unix/sysv/linux/read.c:24
#2  0x76061e78 in  () at /usr/lib/arm-linux-gnueabihf/libjack.so.0
#3  0x76065878 in  () at /usr/lib/arm-linux-gnueabihf/libjack.so.0
#4  0x7606569c in  () at /usr/lib/arm-linux-gnueabihf/libjack.so.0
#5  0x7606096c in  () at /usr/lib/arm-linux-gnueabihf/libjack.so.0
#6  0x76f79300 in start_thread (arg=0x72087440) at pthread_create.c:477
#7  0x76e0b208 in  () at ../sysdeps/unix/sysv/linux/arm/clone.S:73

David Silverman

unread,
Aug 23, 2022, 3:40:45 PM8/23/22
to pyo-discuss
A few more error message in case they help at all:

JackTemporaryException : now quits...
Jack main caught signal 2
Released audio card Audio0
audio_reservation_finish
WARNING: 1 message buffer overruns!


David Silverman

unread,
Sep 4, 2022, 10:28:59 AM9/4/22
to pyo-discuss
Anything else I can do to help debug this SfPlayer failing error?
Reply all
Reply to author
Forward
0 new messages