# INTERNAL PSYCHTOOLBOX ERRORs when running PTB OSX Demos

**URL:** <https://psychtoolbox.discourse.group/t/internal-psychtoolbox-errors-when-running-ptb-osx-demos/1436>\
**Category:** Uncategorized\
**Created:** [September 21, 2005, 10:58pm UTC](https://psychtoolbox.discourse.group/t/internal-psychtoolbox-errors-when-running-ptb-osx-demos/1436 "2005-09-21T22:58:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sethegger1313](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@sethegger1313](https://psychtoolbox.discourse.group/u/sethegger1313)\
**Post date:** [September 21, 2005, 10:58pm UTC](https://psychtoolbox.discourse.group/t/internal-psychtoolbox-errors-when-running-ptb-osx-demos/1436/1 "2005-09-21T22:58:00Z")

</div>

I am having some difficulty implementing any code using PTB and  
matlab; while trying to   
run scripts matlab returns error messages instead of the predicted  
results. Even more   
fustrating is the fact that the error messages all differ from one  
script to the next. Here are the error messages I am getting:  
  
1. While running 'MovieDemoOSX'  
 INTERNAL PSYCHTOOLBOX ERROR  
 error: PsychError\_internal  
 general description: Unspecified error, probably a Psychtoolbox bug  
 specific description: Unrecognized screen depth value  
 module name: Screen  
 subfunction call: DrawText  
 file name: ../../../Source/Common/Screen/ScreenTypes.c  
 function name: PsychGetWhiteValueFromDepthStruct  
 line number: 151  
 ??? (null)  
  
2. While running 'DrawSomeTextOSX'  
 INTERNAL PSYCHTOOLBOX ERROR  
 error: PsychError\_internal  
 general description: Unspecified error, probably a Psychtoolbox bug  
 specific description: Error attempting to coerce color specifier  
 module name: Screen  
 subfunction call: FillRect  
 file name: ../../../Source/Common/Screen/ScreenTypes.c  
 function name: PsychCoerceColorModeFromSizes  
 line number: 304  
  
3. When Trying my own script:  
  
 -----------------------------------------------  
  
 Segmentation violation detected at Wed Sep 21 15:19:10 2005  
  
 -----------------------------------------------  
  
  
 Configuration:  
 MATLAB Version: 6.5.2.203039 (R13) Service Pack 2  
 Operating System: Darwin 7.9.0 Darwin Kernel Version 7.9.0: Wed  
 Mar 30 20:11:17 PST   
 2005; root:xnu/xnu-517.12.7.obj~1/RELEASE\_PPC Power Macintosh  
 Window System: The XFree86 Project, Inc (40300000),  
display:0.0  
 Current Visual: 0x22 (class 4, depth 15)  
 Virtual Machine: Java 1.3.1\_16 with "Apple Computer, Inc." Java  
 HotSpot(TM) Client VM  
 (mixed mode)  
  
 Segmentation violation occurred within signal handler.  
 Unable to complete stack trace (stack was probably corrupted)  
  
 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 in reporting this problem to The MathWorks so  
 that we have the best chance of correcting it:  
  
 1. Send this crash report to [segv@...](mailto:segv@...) for automated  
analysis.  
 For your convenience, this information has been recorded in:  
 /Users/psychophysics/matlab\_crash\_dump.415  
  
 2. Also, if the problem is reproducible, send the crash report to  
[support@...](mailto:support@...) along with:  
 - A specific list of steps that will reproduce the problem  
 - Any M, MEX, MDL or other files required to reproduce the  
problem  
 - Any error messages displayed prior to this crash report  
 A technical support engineer will contact you with further  
information.  
  
 Thank you for your assistance. Please save your workspace and  
restart  
 MATLAB before continuing your work.  
  
 ??? (null)  
  
Even worse, running this script results in a Matlab Crashing and  
prompting me to restart   
before continuing to work in Matlab. Here is the script I am using:  
  
 try  
 whichScreen = 0;  
 nCols = 320;  
 nRows = 240;  
  
 white=WhiteIndex(whichScreen);  
 black=BlackIndex(whichScreen);  
 gray=(white+black)/2;  
 if round(gray)==white  
 gray=black;  
 end  
  
 image1 = (rand(nRows,nCols));  
  
 tex = Screen('MakeTexture',whichScreen,image1\*gray);  
  
 window = Screen('OpenWindow',whichScreen,0,[],32,2);  
  
 Screen('FillRect',window,gray);  
 Screen('Flip',window);  
 Screen('FillRect',window,gray);  
  
 Screen('CloseAll')  
  
 catch  
 Screen('CloseAll')  
 rethrow(lasterror)  
 end  
  
If I take out the call to Screen to 'MakeTexture' then the script no  
longer crashes.  
  
4. DriftDemoOSX runs successfully without any complaint from matlab,  
despite the fact that it calls the same functions as the above  
scripts.  
  
I am currently running PsychToolbox v1.0.1 wiht Matlab 6.5.2 on a  
Dual 1.25 GHz G4 running OSX v10.3.9. If anyone has any insight into  
what is  
preventing me from running scripts successfully, I would much  
appreciate the help.  
  
Thanks for your time,  
Seth Egger

---

<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:** [September 22, 2005, 7:07pm UTC](https://psychtoolbox.discourse.group/t/internal-psychtoolbox-errors-when-running-ptb-osx-demos/1436/2 "2005-09-22T19:07:58Z")

</div>

Hi,  
  
please, always use the latest available release  
of the Psychtoolbox, especially if you experience  
trouble/bugs. Lots of bug-fixes and improvements are  
made in each new release, so your specific bug may be  
fixed already, and PTB 1.0.1 is over a year old!  
  
I would recommend you to download the 1.0.5 from the  
website and then downloading the update from:  
  
\<[http://www.kyb.tuebingen.mpg.de/bu/people/kleinerm/ptbosx/](http://www.kyb.tuebingen.mpg.de/bu/people/kleinerm/ptbosx/)\>  
  
Replace the Screen.mexmac of PTB 1.0.5 with the Screen.mexmac  
in the update and retry.  
  
Possible reasons for your crashes may be:  
  
1. Using an ATI Rage Pro gfx-card -\> unsupported.  
2. Running at a color depths other than "Millions of colors",  
which can cause malfunctions but is not detected by older  
PTB releases.  
  
A few comments to your script:  
  
The safest way is to first open an onscreen window:  
  
w=Screen('OpenWindow', .....)  
  
and then using the window handle 'w' for successive commands  
like Screen('MakeTexture', ...).  
  
Upcoming releases of PTB will require you to do it this way  
in exchange for a much faster, much more capable DrawTexture  
function :-)  
  
  
-mario  
  
  
--- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "sethegger1313" \<sethegger@s...\>  
wrote:  

> \> I am having some difficulty implementing any code using PTB and  
> \> matlab; while trying to   
> \> run scripts matlab returns error messages instead of the predicted  
> \> results. Even more   
> \> fustrating is the fact that the error messages all differ from one  
> \> script to the next. Here are the error messages I am getting:  
> \>   
> \> 1. While running 'MovieDemoOSX'  
> \> INTERNAL PSYCHTOOLBOX ERROR  
> \> error: PsychError\_internal  
> \> general description: Unspecified error, probably a Psychtoolbox

bug  

> \> specific description: Unrecognized screen depth value  
> \> module name: Screen  
> \> subfunction call: DrawText  
> \> file name: ../../../Source/Common/Screen/ScreenTypes.c  
> \> function name: PsychGetWhiteValueFromDepthStruct  
> \> line number: 151  
> \> ??? (null)  
> \>   
> \> 2. While running 'DrawSomeTextOSX'  
> \> INTERNAL PSYCHTOOLBOX ERROR  
> \> error: PsychError\_internal  
> \> general description: Unspecified error, probably a Psychtoolbox

bug  

> \> specific description: Error attempting to coerce color specifier  
> \> module name: Screen  
> \> subfunction call: FillRect  
> \> file name: ../../../Source/Common/Screen/ScreenTypes.c  
> \> function name: PsychCoerceColorModeFromSizes  
> \> line number: 304  
> \>   
> \> 3. When Trying my own script:  
> \>   
> \> -----------------------------------------------  
> \>   
> \> Segmentation violation detected at Wed Sep 21 15:19:10 2005  
> \>   
> \> -----------------------------------------------  
> \>   
> \>   
> \> Configuration:  
> \> MATLAB Version: 6.5.2.203039 (R13) Service Pack 2  
> \> Operating System: Darwin 7.9.0 Darwin Kernel Version 7.9.0:

Wed  

> \> Mar 30 20:11:17 PST   
> \> 2005; root:xnu/xnu-517.12.7.obj~1/RELEASE\_PPC Power Macintosh  
> \> Window System: The XFree86 Project, Inc (40300000),  
> \> display:0.0  
> \> Current Visual: 0x22 (class 4, depth 15)  
> \> Virtual Machine: Java 1.3.1\_16 with "Apple Computer, Inc."

Java  

> \> HotSpot(TM) Client VM  
> \> (mixed mode)  
> \>   
> \> Segmentation violation occurred within signal handler.  
> \> Unable to complete stack trace (stack was probably corrupted)  
> \>   
> \> 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 in reporting this problem to The MathWorks so  
> \> that we have the best chance of correcting it:  
> \>   
> \> 1. Send this crash report to segv@m... for automated  
> \> analysis.  
> \> For your convenience, this information has been recorded in:  
> \> /Users/psychophysics/matlab\_crash\_dump.415  
> \>   
> \> 2. Also, if the problem is reproducible, send the crash report

to  

> \> support@m... along with:  
> \> - A specific list of steps that will reproduce the problem  
> \> - Any M, MEX, MDL or other files required to reproduce the  
> \> problem  
> \> - Any error messages displayed prior to this crash report  
> \> A technical support engineer will contact you with further  
> \> information.  
> \>   
> \> Thank you for your assistance. Please save your workspace and  
> \> restart  
> \> MATLAB before continuing your work.  
> \>   
> \> ??? (null)  
> \>   
> \> Even worse, running this script results in a Matlab Crashing and  
> \> prompting me to restart   
> \> before continuing to work in Matlab. Here is the script I am using:  
> \>   
> \> try  
> \> whichScreen = 0;  
> \> nCols = 320;  
> \> nRows = 240;  
> \>   
> \> white=WhiteIndex(whichScreen);  
> \> black=BlackIndex(whichScreen);  
> \> gray=(white+black)/2;  
> \> if round(gray)==white  
> \> gray=black;  
> \> end  
> \>   
> \> image1 = (rand(nRows,nCols));  
> \>   
> \> tex = Screen('MakeTexture',whichScreen,image1\*gray);  
> \>   
> \> window = Screen('OpenWindow',whichScreen,0,[],32,2);  
> \>   
> \> Screen('FillRect',window,gray);  
> \> Screen('Flip',window);  
> \> Screen('FillRect',window,gray);  
> \>   
> \> Screen('CloseAll')  
> \>   
> \> catch  
> \> Screen('CloseAll')  
> \> rethrow(lasterror)  
> \> end  
> \>   
> \> If I take out the call to Screen to 'MakeTexture' then the script no  
> \> longer crashes.  
> \>   
> \> 4. DriftDemoOSX runs successfully without any complaint from matlab,  
> \> despite the fact that it calls the same functions as the above  
> \> scripts.  
> \>   
> \> I am currently running PsychToolbox v1.0.1 wiht Matlab 6.5.2 on a  
> \> Dual 1.25 GHz G4 running OSX v10.3.9. If anyone has any insight

into  

> \> what is  
> \> preventing me from running scripts successfully, I would much  
> \> appreciate the help.  
> \>   
> \> Thanks for your time,  
> \> Seth Egger
