# crash of PsychPortAudio

**URL:** <https://psychtoolbox.discourse.group/t/crash-of-psychportaudio/512>\
**Category:** Uncategorized\
**Created:** [April 5, 2011, 12:26am UTC](https://psychtoolbox.discourse.group/t/crash-of-psychportaudio/512 "2011-04-05T00:26:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbcai](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@mbcai](https://psychtoolbox.discourse.group/u/mbcai)\
**Post date:** [April 5, 2011, 12:26am UTC](https://psychtoolbox.discourse.group/t/crash-of-psychportaudio/512/1 "2011-04-05T00:26:23Z")

</div>

Dear colleagues,   
I am experiencing problem with PsychPortAudio now. When I typed devices = PsychPortAudio('GetDevices'); the Matlab crashes and give me the following error log. This happens even after I update my psychtoolbox. There is no problem with all visual stimuli. I checked the memory through Matlab and there is still plenty of memory:   
Maximum possible array: 670 MB (7.028e+008 bytes) \*  
Memory available for all arrays: 1487 MB (1.559e+009 bytes) \*\*  
Memory used by MATLAB: 313 MB (3.279e+008 bytes)  
Physical Memory (RAM): 2046 MB (2.145e+009 bytes)  
  
Does anyone know how to deal with this? Thanks very much  
  
Mingbo  
  
  
the following are the error log:  
  
MATLAB crash file:C:\DOCUME~1\mcai\LOCALS~1\Temp\matlab\_crash\_dump.5720  
------------------------------------------------------------------------  
 Segmentation violation detected at Mon Apr 04 19:17:00 2011  
------------------------------------------------------------------------  
  
Configuration:  
 MATLAB Version: 7.6.0.324 (R2008a)  
 MATLAB License: 241991  
 Operating System: Microsoft Windows XP  
 Window System: Version 5.1 (Build 2600: Service Pack 3)  
 Processor ID: x86 Family 6 Model 7 Stepping 6, GenuineIntel  
 Virtual Machine: Java 1.6.0 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode  
 Default Encoding: windows-1252  
  
Fault Count: 1  
  
Register State:  
 EAX = 00d3e300 EBX = 00000000  
 ECX = 00000000 EDX = 00000000  
 ESI = 00d3e3c8 EDI = 00000000  
 EBP = 00d3e350 ESP = 00d3e2fc  
 EIP = 7c812afb FLG = 00000202  
  
Stack Trace:  
 [0] kernel32.dll:0x7c812afb(0xc06d007e, 0, 1, 0x00d3e3c4 "tÃ£Ã"")  
 [1] PsychPortAudio.mexw32:0x14df9b1f(24, 0x00d3e374, 0x14e1423c "Open GetDeviceSettings ", 0)  
 [2] PsychPortAudio.mexw32:0x14df8bf1(0x1660c688, 0, 0, 0x14e14254 "DeviceIndex")  
 [3] PsychPortAudio.mexw32:0x14df3a2d(0, 0, 0, 0)  
 [4] PsychPortAudio.mexw32:0x14de60dc(1, 0x00d3eb64, 1, 0x00d3ebc4)  
 [5] libmex.dll:\_mexRunMexFile(1, 0x00d3eb64, 1, 0x00d3ebc4) + 129 bytes  
 [6] libmex.dll:private: void \_\_thiscall Mfh\_mex::runMexFileWithSignalProtection(int,struct mxArray\_tag \* \*,int,struct mxArray\_tag \* \*)(1, 0x00d3eb64, 1, 0x00d3ebc4) + 73 bytes  
 [7] libmex.dll:public: virtual void \_\_thiscall Mfh\_mex::dispatch\_file(int,struct mxArray\_tag \* \*,int,struct mxArray\_tag \* \*)(1, 0x00d3eb64, 1, 0x00d3ebc4) + 220 bytes  
 [8] m\_dispatcher.dll:public: virtual void \_\_thiscall Mfh\_file::dispatch\_fh(int,struct mxArray\_tag \* \*,int,struct mxArray\_tag \* \*)(1, 0x00d3eb64, 1, 0x00d3ebc4) + 193 bytes  
 [9] m\_interpreter.dll:\_\_catch$?inDispatchFromStack@@YAHHPBDHH@Z$0(575, 0x0421a3cc "PsychPortAudio", 1, 1) + 712 bytes  
 [10] m\_interpreter.dll:enum opcodes \_\_cdecl inDispatchCall(char const \*,int,int,int,int \*,int \*)(0x0421a3cc "PsychPortAudio", 575, 1, 1) + 146 bytes  
 [11] m\_interpreter.dll:int \_\_cdecl inInterp(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest\_tag volatile \*,int \*)(1, 0, 1, 0) + 2898 bytes  
 [12] m\_interpreter.dll:int \_\_cdecl protected\_inInterp(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest\_tag \*,int \*)(1, 0, 1, 0) + 74 bytes  
 [13] m\_interpreter.dll:int \_\_cdecl inInterPcodeSJ(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest\_tag \*,int \*)(1, 0, 1, 0) + 254 bytes  
 [14] m\_interpreter.dll:int \_\_cdecl inExecuteMFunctionOrScript(class Mfh\_mp \*,bool)(0x1a466e60, 0x1a466e01, 0xffffffff, 0x1a466e60) + 1330 bytes  
 [15] m\_interpreter.dll:void \_\_cdecl inRunMfile(int,struct mxArray\_tag \* \*,int,struct mxArray\_tag \* \*,class Mfh\_mp \*,struct inWorkSpace\_tag \*)(0, 0x00d3f3cc, 0, 0) + 679 bytes  
 [16] m\_interpreter.dll:public: virtual void \_\_thiscall Mfh\_mp::dispatch\_file(struct \_mdUnknown\_workspace \*,int,struct mxArray\_tag \* \*,int,struct mxArray\_tag \* \*)(0, 0, 0x00d3f3cc, 0) + 29 bytes  
 [17] m\_interpreter.dll:public: virtual void \_\_thiscall Mfh\_mp::dispatch\_file(int,struct mxArray\_tag \* \*,int,struct mxArray\_tag \* \*)(0, 0x00d3f3cc, 0, 0) + 28 bytes  
 [18] m\_dispatcher.dll:public: virtual void \_\_thiscall Mfh\_file::dispatch\_fh(int,struct mxArray\_tag \* \*,int,struct mxArray\_tag \* \*)(0, 0x00d3f3cc, 0, 0) + 193 bytes  
 [19] m\_interpreter.dll:void \_\_cdecl inEvalPcodeHeaderToWord(struct \_memory\_context \*,int,struct mxArray\_tag \* \* const,struct \_pcodeheader \*,class Mfh\_mp \*,unsigned long)(0x7ad2e5e4, 0, 0x00d3f3cc, 0x00d3f288) + 201 bytes  
 [20] m\_interpreter.dll:enum inExecutionStatus \_\_cdecl in\_local\_call\_script\_function(struct \_memory\_context \*,struct \_pcodeheader \*,int,struct mxArray\_tag \* \* const,unsigned long,bool)(0x7ad2e5e4, 0x00d3f288, 0, 0x00d3f3cc) + 91 bytes  
 [21] m\_interpreter.dll:enum inExecutionStatus \_\_cdecl inEvalStringWithIsVarFcn(struct \_memory\_context \*,char const \*,enum EvalType,int,struct mxArray\_tag \* \* const,enum inDebugCheck,struct \_pcodeheader \*,int \*,bool (\_\_cdecl\*)(void \*,char const \*),void \*,bool,bool)(0x7ad2e5e4, 0x041add20 "devices = PsychPortAudio('GetDev..", 0, 0) + 570 bytes  
 [22] m\_interpreter.dll:enum inExecutionStatus \_\_cdecl inEvalCmdWithLocalReturn(char const \*,int \*,bool,bool,bool (\_\_cdecl\*)(void \*,char const \*))(0x041add20 "devices = PsychPortAudio('GetDev..", 0, 1, 0x79cad700) + 97 bytes  
 [23] m\_interpreter.dll:\_inEvalCmdWithLocalReturn(0x041add20 "devices = PsychPortAudio('GetDev..", 0, 0, 1) + 28 bytes  
 [24] bridge.dll:enum inExecutionStatus \_\_cdecl evalCommandWithLongjmpSafety(char const \*)(0x041add20 "devices = PsychPortAudio('GetDev..", 0x01ed3150, 0x01ed31b0, 0x01ed3150) + 67 bytes  
 [25] bridge.dll:\_\_catch$\_mnParser$0(0x01ed3150, 0x16329668, 0x79730101, 0x166a1380) + 294 bytes  
 [26] mcr.dll:public: void \_\_thiscall mcrInstance::mnParser(void)(0x004043ec, 336696, 0, 0x6d5c3a43) + 51 bytes  
 [27] MATLAB.exe:\_WinMain@16(0x01ed31b0, 0, 336696, 0x01ed3150) + 405 bytes  
 [28] MATLAB.exe:\_\_\_tmainCRTStartup(0, 0, 0x7ffd8000, 0x8054b6ed) + 320 bytes  
 [29] kernel32.dll:0x7c817077(0x00401943, 0, 0x00905a4d, 3)  
  
This error was detected while a MEX-file was running. If the MEX-file  
is not an official MathWorks function, please examine its source code  
for errors. Please consult the External Interfaces Guide for information  
on debugging MEX-files.  
  
If it is an official MathWorks function, please  
follow these steps to report this problem to The MathWorks so we  
have the best chance of correcting it:  
  
The next time MATLAB is launched under typical usage, a dialog box will  
open to help you send the error log to The MathWorks. Alternatively, you  
can send an e-mail to [segv@...](mailto:segv@...) with the following file attached:  
 C:\DOCUME~1\mcai\LOCALS~1\Temp\matlab\_crash\_dump.5720  
  
If the problem is reproducible, please submit a Service Request via:  
[http://www.mathworks.com/support/contact\_us/ts/help\_request\_1.html](http://www.mathworks.com/support/contact_us/ts/help_request_1.html)  
  
A technical support engineer might contact you with further information.  
  
Thank you for your help. MATLAB may attempt to recover, but even if recovery appears successful,  
we recommend that you save your workspace and restart MATLAB as soon as possible.

---

<div class="post-metadata">

**Author:** ![denis.pelli](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/denis.pelli/32/7_2.png) [@denis.pelli](https://psychtoolbox.discourse.group/u/denis.pelli)\
**Post date:** [May 7, 2020, 9:32pm UTC](https://psychtoolbox.discourse.group/t/crash-of-psychportaudio/512/2 "2020-05-07T21:32:55Z")

</div>

Dear Mario  
I too get an occasional fatal error due to the PsychPortAudio driver. (I’m in macOS Mojave, MacBook Pro, latest Psychtoolbox.) My student Ashley Feng shared with me a screenshot of a failure today. This happens roughly once a week to one or another of my students. Once the PsychPortAudio driver fails, this failure occurs every time until we do a “clear all”, and then everything is back to normal. I want to suggest a quick fix that might help a lot in reducing the effect of the bug on users.

The screenshot below shows that the failure occurred in function GetStatus in PsychPortAudio.  
Could that code be wrapped in a try-catch with a “clear PsychPortAudio” in the catch block?  
Best  
Denis

 ![image](https://global.discourse-cdn.com/free1/uploads/psychtoolbox/original/1X/a4a85ae4103f744398ff6ffd18eee49765425f2f.jpeg)

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [May 9, 2020, 1:30am UTC](https://psychtoolbox.discourse.group/t/crash-of-psychportaudio/512/3 "2020-05-09T01:30:27Z")

</div>

This is not a crash, because Matlab wasn’t crashed, but an error abort with an error message that tells you about the problem. Less drama please.

Most likely somebody did `clear PsychPortAudio` or `clear Snd` after some kind of error, or in a script (i see a `clear KbWait` in that text editor, which hints at this pattern of wrong use). A `clear all` is what one should do after an error or to reset things. Everything else will just leave various mex files or M-files with some stale state, inconsistent with other M-files or mex files, as various files do cache some state across invocations for performance reasons.

-mario
