Open LOGUNIVPM opened 1 year ago
Hi, hope someone can give me some hints to debug the problem.
The problem has a minimum working example that is simple as that: open a terminal and call python3, then in the python commandline just type: import sounddevice
The python commandline will NEVER return, so you are stuck.
I also removed the video card, just in case the hdmi out create problems, but nothing improved.
More info:
[ 71.162615] BUG: kernel NULL pointer dereference, address: 0000000000000000
[ 71.162628] #PF: supervisor instruction fetch in kernel mode
[ 71.162633] #PF: error_code(0x0010) - not-present page
[ 71.162638] PGD 16a91b067 P4D 16a91b067 PUD 16a91c067 PMD 0
[ 71.162649] Oops: 0010 [#1] SMP NOPTI
[ 71.162657] CPU: 11 PID: 2622 Comm: python3 Not tainted 5.15.0-50-generic #56~20.04.1-Ubuntu
[ 71.162666] Hardware name: Intel(R) Client Systems NUC9i9QNX/NUC9i9QNB, BIOS QXCFL579.0054.2020.0810.2239 08/10/2020
[ 71.162670] RIP: 0010:0x0
[ 71.162683] Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.
[ 71.162687] RSP: 0018:ffffb77bc1d7f820 EFLAGS: 00010202
[ 71.162693] RAX: 0000000000000000 RBX: ffff9ce7d3a40600 RCX: 0000000000000007
[ 71.162699] RDX: ffff9ce7c7b77800 RSI: ffff9ce7c6f78028 RDI: ffff9ce7d3a40660
[ 71.162703] RBP: ffffb77bc1d7f848 R08: 000000000000006c R09: ffff9ce7d81723c7
[ 71.162708] R10: 0000000000000007 R11: ffffffffc0b1159c R12: ffff9ce7c7b77800
[ 71.162712] R13: 0000000000000001 R14: ffff9ce7c6f78028 R15: ffff9ce7d1bfc128
[ 71.162716] FS: 00007f17a10ce740(0000) GS:ffff9cef60ec0000(0000) knlGS:0000000000000000
[ 71.162723] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 71.162728] CR2: ffffffffffffffd6 CR3: 0000000117db6005 CR4: 00000000003706e0
[ 71.162733] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 71.162737] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 71.162741] Call Trace:
[ 71.162745]
Wow, that sounds mysterious!
I don't really have a clue what could go wrong there, but there is one thing you could try: you could disable the call to _initialize()
:
This should at least let you import sounddevice as sd
.
After that, you can manually call sd._lib.Pa_Initialize()
and see if that works.
If that works, the problem has likely to do with the redirection of stderr
output, which is done in _initialize()
.
If not, I guess that's a problem with the underlying PortAudio library.
This issue may or may not be related: #90.
Hi, I only had now the chance to try it.
Commenting the Initialize() solves the crash. This is what happens when I later do the Initialize manually:
Python 3.9.14 (main, Sep 7 2022, 23:43:29)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sounddevice as sd
>>> sd._lib.Pa_Initialize()
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card
ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card
ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card
ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card
ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card
ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card
ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM dmix
0
Thanks for the update!
According to your output, Pa_Initialize()
is successful.
The many error messages are expected, and are the reason why I'm trying to redirect stderr
.
So the problem indeed seems to be caused by the redirection. Can you please try the minimal reproducing example from https://github.com/spatialaudio/python-sounddevice/issues/90#issuecomment-1182709958?
Can you please try if #444 works?
Yes, the fix works! I followed your commits in #444 I assume that the problem is already fixed if instead of installing with pip, one clones sounddevice from the github repo, right?
Thanks for checking this!
I assume that the problem is already fixed if instead of installing with pip, one clones sounddevice from the github repo, right?
No, it's not yet merged into this repo, because it hasn't been tested on Windows yet. But you should be able to install it with something like:
python3 -m pip install git+https://github.com/mgeier/python-sounddevice@redirect-with-dup2
Uhm, is the branch redirect-with-dup2 correct? I installed that but still get the kernel fault.
Here's a bit more detail with respect to my previous comment.
On the same machine where I had previously fixed the issue with success I reinstalled Ubuntu, this time the 2022 LTS instead of the 2020 one. I installed the redirect-with-dup2 branch for sounddevice and I stumbled in the same issue.
I have reviewed the code, made some changes and I see that the kernel fault is triggered by Pa_initialize:
_check(_lib.Pa_Initialize(), 'Error initializing PortAudio')
I will revert to Ubuntu 2020 LTS and see if things get solved...
Thanks for the update!
If Pa_Initialize()
makes problems, there isn't much I can do on the Python side, this would have to be reported to the PortAudio project.
But it seems that os.dup()
and os.dup2()
are working, that's good to know.
Hi all, I've been using a small GUI application written in python 3 and kivy that uses sounddevice to record and analyze audio.
This works well on my Linux mint 19 machine. Now I am launching the application on a fresh Ubuntu 20 install on a NUC and I have the following problem: on application launch I see a black GUI, nothing happens, the application can't be killed (not even with kill -9 from command line). I have started debugging the application from PyCharm and it seems that the program is locked on import sounddevice. After that line the debugger loses control and can't even kill the application. Maybe sounddevice got the wrong audio card and gets lost? I don't know...
I've got Ubuntu 20.04.4 on a NUC 9i9 with: Card: sof-hda-dsp Chip: Realtek ALC256 and a graphic card: product: TU117 [GeForce GTX 1650] [10DE:1F82] which is also seen as audio device (through HDMI) and also Chip: Nvidia GPU 94 HDMI/DP
Currently I have the nuveau drivers installed but the official nvidia drivers behave the same. What can be wrong?!