Python experiment crashes at random points during run

I am currently running a Python experiment for a research study where we present various types of stimuli (i.e. audio, visual, audiovisual), but the program tends to (not always, but most of the time) crash at random points throughout the run. The main error that appears is as follows:

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

During the run, the following warning pops up multiple times:

ALSA lib pcm.c: 8526 : (snd_pcm_recover) underrun occurred

I have tried running the code on Psychopy and Pycharm, but both present the same issue.

One change I made was on audio.py, where I deleted “from .” in “from . import audio” because it helped me get rid of the following error:

AttributeError: ‘_MasterStream’ object has no attribute 'handle’

I don’t know if that could be a cause of the error I am getting.

We are running this experiment on both a Linux Ubuntu 20.04.3 LTS and a Windows computer (PyschoPy v2022.1.4). However, the program only crashes on the Linux computer, not the Windows.

Every time I open PsychoPy on the Linux, it says:

For optimal performance on Linux, Psychtoolbox requires additional configuration changes to be made to this system by entering the following commands into your terminal:

sudo groupadd -force psychopy
sudo usermod -a -G psychopy $USER
sudo gedit /etc/security/limits.d/99-psychopylimits.conf
@psychopy -nice -20
@psychopy -rtprio 50
@psychopy -memlock unlimited

This may be the root of the problem, but I do not have permission from my computer to enter sudo code on the terminal.