# Screen(&#39;CloseAll&#39;) crashes Matlab and Java

**URL:** <https://psychtoolbox.discourse.group/t/screen-39-closeall-39-crashes-matlab-and-java/299>\
**Category:** Uncategorized\
**Created:** [August 13, 2013, 6:04pm UTC](https://psychtoolbox.discourse.group/t/screen-39-closeall-39-crashes-matlab-and-java/299 "2013-08-13T18:04:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [August 13, 2013, 6:04pm UTC](https://psychtoolbox.discourse.group/t/screen-39-closeall-39-crashes-matlab-and-java/299/1 "2013-08-13T18:04:44Z")

</div>

Hi,  
  
I'm experiencing a weird crash when calling Screen('CloseAll') on Windows 7 64bit Matalb R2013a. The crash freezes Matlab and apparently also crashes Java, because Matlab won't start after such a crash until I reboot, unless I execute java.exe from my Start Menu.  
  
This happens in the following scenario:  
  
I use PTB to display some stimulus, including a geometric correction for cylindrical projection as described in DisplayUndistortionHalfCylinder.  
  
In my Matlab code, I wrap everything, starting from where the PTB window is opened, in a try...catch statement. To make debugging easier, the catch statement calls Screen('CloseAll') to close the screen before rethrowing the error.  
  
It seems that this Screen('CloseAll') in the catch statement causes the crash described above. If I remove it, there's no crash. When I call Screen('CloseAll') after exiting debug mode, there's also no crash.  
  
In all cases, the error causing the try...catch to trigger is something trivial in an unrelated part of code.  
  
I'm doing all this on my four year old laptop, which I use for development. Could it be that the crash is due to my old graphics hardware not being able to deal with the geometric undistortion or so?  
  
If you have an idea what the problem might be, that would be great. I could try to write a minimal code example but it would be quite some work, so I'll try without first.  
  
Thanks!

---

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [August 13, 2013, 10:51pm UTC](https://psychtoolbox.discourse.group/t/screen-39-closeall-39-crashes-matlab-and-java/299/2 "2013-08-13T22:51:17Z")

</div>

PS: Matlab also crashes when, in the situation described above, I say "clear all" to clear the previous PsychImaging session.

---

<div class="post-metadata">

**Author:** ![mmortal03](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@mmortal03](https://psychtoolbox.discourse.group/u/mmortal03)\
**Post date:** [August 13, 2013, 11:50pm UTC](https://psychtoolbox.discourse.group/t/screen-39-closeall-39-crashes-matlab-and-java/299/3 "2013-08-13T23:50:01Z")

</div>

Could very well be related to the crashing bug we've been experiencing in the thread "A serious persistent bug". I'm going to give your test case a shot on my computer and see.  

  
  

> On Tue, Aug 13, 2013 at 6:51 PM, qiagenmidikit \<[qiagenmidikit@...](mailto:qiagenmidikit@...)\> wrote:  
> 
> > PS: Matlab also crashes when, in the situation described above, I say "clear all" to clear the previous PsychImaging session.

---

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [August 14, 2013, 3:39pm UTC](https://psychtoolbox.discourse.group/t/screen-39-closeall-39-crashes-matlab-and-java/299/4 "2013-08-14T15:39:05Z")

</div>

OK a code example indeed makes things more clear: It seems now that the crash is connected to using PsychImaging (rather than Screen), combined with setting a BlendFunction, combined with Screen('CloseAll') and 'clear all'. The code below reliably causes matlab to crash for me (although without the effect on Java that I described above).  
  
If I open the window with Screen('OpenWindow') and remove all the PsychImaging calls, there is no crash.  
  
If I remove the BlendFunction call, there is no crash.  
  
If I remove the clear all at the end, there is also no crash (this is different from my real code where I first got that crash, because my real code does not contain a clear all).  
  
So this doesn't seem to have anything todo with the try/catch.  
  
There is no useful error output from matlab. It crashes hard and then does not show any report at the start of the next session.  
  
What system specs do you need?  
- ThinkPad X200 tablet  
- Intel Core 2 Duo  
- 8 GB RAM  
- 64-bit Windows 7  
- Dual monitor setup (internal + external).  
  
PTB-INFO: OpenGL-Renderer is Intel :: Mobile Intel(R) 4 Series Express Chipset Family :: 2.1.0 - Build 8.15.10.2302  
OpenGL-Vendor / renderer / version are: Intel - Mobile Intel(R) 4 Series Express Chipset Family - 2.1.0 - Build 8.15.10.2302  
  
OpenGL-Extensions are: GL\_EXT\_blend\_minmax GL\_EXT\_blend\_subtract GL\_EXT\_blend\_color GL\_EXT\_abgr GL\_EXT\_texture3D GL\_EXT\_clip\_volume\_hint GL\_EXT\_compiled\_vertex\_array GL\_SGIS\_texture\_edge\_clamp GL\_SGIS\_generate\_mipmap GL\_EXT\_draw\_range\_elements GL\_SGIS\_texture\_lod GL\_EXT\_rescale\_normal GL\_EXT\_packed\_pixels GL\_EXT\_texture\_edge\_clamp GL\_EXT\_separate\_specular\_color GL\_ARB\_multitexture GL\_EXT\_texture\_env\_combine GL\_EXT\_bgra GL\_EXT\_blend\_func\_separate GL\_EXT\_secondary\_color GL\_EXT\_fog\_coord GL\_EXT\_texture\_env\_add GL\_ARB\_texture\_cube\_map GL\_ARB\_transpose\_matrix GL\_ARB\_texture\_env\_add GL\_IBM\_texture\_mirrored\_repeat GL\_EXT\_multi\_draw\_arrays GL\_NV\_blend\_square GL\_ARB\_texture\_compression GL\_3DFX\_texture\_compression\_FXT1 GL\_EXT\_texture\_filter\_anisotropic GL\_ARB\_texture\_border\_clamp GL\_ARB\_point\_parameters GL\_ARB\_texture\_env\_combine GL\_ARB\_texture\_env\_dot3 GL\_ARB\_texture\_env\_crossbar GL\_EXT\_texture\_compression\_s3tc GL\_ARB\_shadow GL\_ARB\_window\_pos GL\_EXT\_shadow\_funcs GL\_EXT\_stencil\_wrap GL\_ARB\_vertex\_program GL\_EXT\_texture\_rectangle GL\_ARB\_fragment\_program GL\_EXT\_stencil\_two\_side GL\_ATI\_separate\_stencil GL\_ARB\_vertex\_buffer\_object GL\_EXT\_texture\_lod\_bias GL\_ARB\_occlusion\_query GL\_ARB\_fragment\_shader GL\_ARB\_shader\_objects GL\_ARB\_shading\_language\_100 GL\_ARB\_texture\_non\_power\_of\_two GL\_ARB\_vertex\_shader GL\_NV\_texgen\_reflection GL\_ARB\_point\_sprite GL\_EXT\_blend\_equation\_separate GL\_ARB\_depth\_texture GL\_ARB\_texture\_rectangle GL\_ARB\_draw\_buffers GL\_ARB\_color\_buffer\_float GL\_ARB\_half\_float\_pixel GL\_ARB\_texture\_float GL\_ARB\_pixel\_buffer\_object GL\_EXT\_framebuffer\_object GL\_ARB\_draw\_instanced GL\_ARB\_half\_float\_vertex GL\_EXT\_draw\_buffers2 GL\_WIN\_swap\_hint GL\_EXT\_texture\_sRGB GL\_EXT\_packed\_float GL\_EXT\_texture\_shared\_exponent GL\_ARB\_texture\_rg GL\_ARB\_texture\_compression\_rgtc GL\_NV\_conditional\_render GL\_EXT\_texture\_swizzle GL\_ARB\_framebuffer\_sRGB GL\_EXT\_packed\_depth\_stencil GL\_ARB\_depth\_buffer\_float GL\_EXT\_transform\_feedback GL\_EXT\_framebuffer\_blit GL\_ARB\_vertex\_array\_object   
  
  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
% My code example:  
  
Screen('Preference', 'SkipSyncTests', 1);  
  
% win = Screen('OpenWindow', 1, 255/2);  
PsychImaging('PrepareConfiguration');  
PsychImaging('AddTask', 'AllViews', 'GeometryCorrection', 'D:\SkyDrive\Documents\MATLAB\lab\angleTask\undistortionConfigTest.mat');  
win = PsychImaging('OpenWindow', 1, 255/2);  
  
Screen('BlendFunction', win, GL\_SRC\_ALPHA, GL\_ONE\_MINUS\_SRC\_ALPHA);  
  
for i = 1:(2\*60)  
 Screen('Flip', win);  
end  
  
Screen('CloseAll')  
clear all  
  
% Code example end  
  

> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "Mario" \<mario.kleiner@...\> wrote:  
> \>  
> \>   
> \>   
> \> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "qiagenmidikit" \<qiagenmidikit@\> wrote:  
> \> \>  
> \> \> Hi,  
> \> \>   
> \> \> I'm experiencing a weird crash when calling Screen('CloseAll') on Windows 7 64bit Matalb R2013a. The crash freezes Matlab and apparently also crashes Java, because Matlab won't start after such a crash until I reboot, unless I execute java.exe from my Start Menu.  
> \> \>   
> \> \> This happens in the following scenario:  
> \> \>   
> \> \> I use PTB to display some stimulus, including a geometric correction for cylindrical projection as described in DisplayUndistortionHalfCylinder.  
> \> \>   
> \> \> In my Matlab code, I wrap everything, starting from where the PTB window is opened, in a try...catch statement. To make debugging easier, the catch statement calls Screen('CloseAll') to close the screen before rethrowing the error.  
> \> \>   
> \> \> It seems that this Screen('CloseAll') in the catch statement causes the crash described above. If I remove it, there's no crash. When I call Screen('CloseAll') after exiting debug mode, there's also no crash.  
> \> \>   
> \>   
> \> That's indeed weird. Our demos call Screen('CloseAll') all the time from the catch branch of try-catch and this doesn't cause crashes. We usually call sca; which does other cleanup work besides Screen('CloseAll').  
> \>   
> \> \> In all cases, the error causing the try...catch to trigger is something trivial in an unrelated part of code.  
> \> \>   
> \> \> I'm doing all this on my four year old laptop, which I use for development. Could it be that the crash is due to my old graphics hardware not being able to deal with the geometric undistortion or so?  
> \> \>  
> \>   
> \> No. Of course one can not exclude the probability of odd graphics driver bugs, but in general pretty much any graphics card since around 2006/2007 should be able to do this without trouble.  
> \>   
> \> \> If you have an idea what the problem might be, that would be great. I could try to write a minimal code example but it would be quite some work, so I'll try without first.  
> \> \>   
> \>   
> \> Example code that reproduces it is a good idea. Also the full system specs. Does the crash produce any useable output, e.g., crash messages with stack traces etc.?  
> \>   
> \> -mario  
> \>

---

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [August 14, 2013, 5:33pm UTC](https://psychtoolbox.discourse.group/t/screen-39-closeall-39-crashes-matlab-and-java/299/5 "2013-08-14T17:33:47Z")

</div>

That's because the script expects a calibration file at the path provided in the call to PsychImaging('AddTask',...). Such a file can be created with DisplayUndistortionHalfCylinder.

---

<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:** [August 14, 2013, 9:49pm UTC](https://psychtoolbox.discourse.group/t/screen-39-closeall-39-crashes-matlab-and-java/299/6 "2013-08-14T21:49:14Z")

</div>

This sounds like an Intel graphics driver bug. Especially the Screen('Blendfunction') call. There's nothing in there that could cause this behaviour, except if the graphics driver has some weird bug - In which case there isn't really anything we could do.  
  
What happens if you leave PsychImaging('PrepareConfiguration/OpenWindow) calls in place and only remove the PsychImaging('AddTask', ...) statement? In that case it would behave like Screen('Openwindow',...); the only difference being that it executes some Java cleanup code on MS-Windows by calling PsychJavaSwingCleanup.m, something that is meant to prevent the infamous java.lang.outOfHeapSpace errors one sometimes sees on Windows with Matlab due to some Matlab Java bugs.  
  
What happens if you call Screen('Blendfunction', win, GL\_ONE, GL\_ZERO); before the Screen('CloseAll') or clear all call? This would restore alpha-blending to the original state before that function was used?  
  
I assume your Psychtoolbox is up to date?  
Do other demos with Screen('Blendfunction') work?  
  
You could try updating your graphics driver and hope for the best. In my experience, Intel gfx + MS-Windows == Trouble due to lots of driver bugs.  
  
-mario  
  
  
--- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "qiagenmidikit" \<qiagenmidik  
it@...\> wrote:  

> \>  
> \> OK a code example indeed makes things more clear: It seems now that the crash is connected to using PsychImaging (rather than Screen), combined with setting a BlendFunction, combined with Screen('CloseAll') and 'clear all'. The code below reliably causes matlab to crash for me (although without the effect on Java that I described above).  
> \>   
> \> If I open the window with Screen('OpenWindow') and remove all the PsychImaging calls, there is no crash.  
> \>   
> \> If I remove the BlendFunction call, there is no crash.  
> \>   
> \> If I remove the clear all at the end, there is also no crash (this is different from my real code where I first got that crash, because my real code does not contain a clear all).  
> \>   
> \> So this doesn't seem to have anything todo with the try/catch.  
> \>   
> \> There is no useful error output from matlab. It crashes hard and then does not show any report at the start of the next session.  
> \>   
> \> What system specs do you need?  
> \> - ThinkPad X200 tablet  
> \> - Intel Core 2 Duo  
> \> - 8 GB RAM  
> \> - 64-bit Windows 7  
> \> - Dual monitor setup (internal + external).  
> \>   
> \> PTB-INFO: OpenGL-Renderer is Intel :: Mobile Intel(R) 4 Series Express Chipset Family :: 2.1.0 - Build 8.15.10.2302  
> \> OpenGL-Vendor / renderer / version are: Intel - Mobile Intel(R) 4 Series Express Chipset Family - 2.1.0 - Build 8.15.10.2302  
> \>   
> \> OpenGL-Extensions are: GL\_EXT\_blend\_minmax GL\_EXT\_blend\_subtract GL\_EXT\_blend\_color GL\_EXT\_abgr GL\_EXT\_texture3D GL\_EXT\_clip\_volume\_hint GL\_EXT\_compiled\_vertex\_array GL\_SGIS\_texture\_edge\_clamp GL\_SGIS\_generate\_mipmap GL\_EXT\_draw\_range\_elements GL\_SGIS\_texture\_lod GL\_EXT\_rescale\_normal GL\_EXT\_packed\_pixels GL\_EXT\_texture\_edge\_clamp GL\_EXT\_separate\_specular\_color GL\_ARB\_multitexture GL\_EXT\_texture\_env\_combine GL\_EXT\_bgra GL\_EXT\_blend\_func\_separate GL\_EXT\_secondary\_color GL\_EXT\_fog\_coord GL\_EXT\_texture\_env\_add GL\_ARB\_texture\_cube\_map GL\_ARB\_transpose\_matrix GL\_ARB\_texture\_env\_add GL\_IBM\_texture\_mirrored\_repeat GL\_EXT\_multi\_draw\_arrays GL\_NV\_blend\_square GL\_ARB\_texture\_compression GL\_3DFX\_texture\_compression\_FXT1 GL\_EXT\_texture\_filter\_anisotropic GL\_ARB\_texture\_border\_clamp GL\_ARB\_point\_parameters GL\_ARB\_texture\_env\_combine GL\_ARB\_texture\_env\_dot3 GL\_ARB\_texture\_env\_crossbar GL\_EXT\_texture\_compression\_s3tc GL\_ARB\_shadow GL\_ARB\_window\_pos GL\_EXT\_shadow\_funcs GL\_EXT\_stencil\_wrap GL\_ARB\_vertex\_program GL\_EXT\_texture\_rectangle GL\_ARB\_fragment\_program GL\_EXT\_stencil\_two\_side GL\_ATI\_separate\_stencil GL\_ARB\_vertex\_buffer\_object GL\_EXT\_texture\_lod\_bias GL\_ARB\_occlusion\_query GL\_ARB\_fragment\_shader GL\_ARB\_shader\_objects GL\_ARB\_shading\_language\_100 GL\_ARB\_texture\_non\_power\_of\_two GL\_ARB\_vertex\_shader GL\_NV\_texgen\_reflection GL\_ARB\_point\_sprite GL\_EXT\_blend\_equation\_separate GL\_ARB\_depth\_texture GL\_ARB\_texture\_rectangle GL\_ARB\_draw\_buffers GL\_ARB\_color\_buffer\_float GL\_ARB\_half\_float\_pixel GL\_ARB\_texture\_float GL\_ARB\_pixel\_buffer\_object GL\_EXT\_framebuffer\_object GL\_ARB\_draw\_instanced GL\_ARB\_half\_float\_vertex GL\_EXT\_draw\_buffers2 GL\_WIN\_swap\_hint GL\_EXT\_texture\_sRGB GL\_EXT\_packed\_float GL\_EXT\_texture\_shared\_exponent GL\_ARB\_texture\_rg GL\_ARB\_texture\_compression\_rgtc GL\_NV\_conditional\_render GL\_EXT\_texture\_swizzle GL\_ARB\_framebuffer\_sRGB GL\_EXT\_packed\_depth\_stencil GL\_ARB\_depth\_buffer\_float GL\_EXT\_transform\_feedback GL\_EXT\_framebuffer\_blit GL\_ARB\_vertex\_array\_object   
> \>   
> \>   
> \> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
> \> % My code example:  
> \>   
> \> Screen('Preference', 'SkipSyncTests', 1);  
> \>   
> \> % win = Screen('OpenWindow', 1, 255/2);  
> \> PsychImaging('PrepareConfiguration');  
> \> PsychImaging('AddTask', 'AllViews', 'GeometryCorrection', 'D:\SkyDrive\Documents\MATLAB\lab\angleTask\undistortionConfigTest.mat');  
> \> win = PsychImaging('OpenWindow', 1, 255/2);  
> \>   
> \> Screen('BlendFunction', win, GL\_SRC\_ALPHA, GL\_ONE\_MINUS\_SRC\_ALPHA);  
> \>   
> \> for i = 1:(2\*60)  
> \> Screen('Flip', win);  
> \> end  
> \>   
> \> Screen('CloseAll')  
> \> clear all  
> \>   
> \> % Code example end  
> \>   
> \> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "Mario" \<mario.kleiner@\> wrote:  
> \> \>  
> \> \>   
> \> \>   
> \> \> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "qiagenmidikit" \<qiagenmidikit@\> wrote:  
> \> \> \>  
> \> \> \> Hi,  
> \> \> \>   
> \> \> \> I'm experiencing a weird crash when calling Screen('CloseAll') on Windows 7 64bit Matalb R2013a. The crash freezes Matlab and apparently also crashes Java, because Matlab won't start after such a crash until I reboot, unless I execute java.exe from my Start Menu.  
> \> \> \>   
> \> \> \> This happens in the following scenario:  
> \> \> \>   
> \> \> \> I use PTB to display some stimulus, including a geometric correction for cylindrical projection as described in DisplayUndistortionHalfCylinder.  
> \> \> \>   
> \> \> \> In my Matlab code, I wrap everything, starting from where the PTB window is opened, in a try...catch statement. To make debugging easier, the catch statement calls Screen('CloseAll') to close the screen before rethrowing the error.  
> \> \> \>   
> \> \> \> It seems that this Screen('CloseAll') in the catch statement causes the crash described above. If I remove it, there's no crash. When I call Screen('CloseAll') after exiting debug mode, there's also no crash.  
> \> \> \>   
> \> \>   
> \> \> That's indeed weird. Our demos call Screen('CloseAll') all the time from the catch branch of try-catch and this doesn't cause crashes. We usually call sca; which does other cleanup work besides Screen('CloseAll').  
> \> \>   
> \> \> \> In all cases, the error causing the try...catch to trigger is something trivial in an unrelated part of code.  
> \> \> \>   
> \> \> \> I'm doing all this on my four year old laptop, which I use for development. Could it be that the crash is due to my old graphics hardware not being able to deal with the geometric undistortion or so?  
> \> \> \>  
> \> \>   
> \> \> No. Of course one can not exclude the probability of odd graphics driver bugs, but in general pretty much any graphics card since around 2006/2007 should be able to do this without trouble.  
> \> \>   
> \> \> \> If you have an idea what the problem might be, that would be great. I could try to write a minimal code example but it would be quite some work, so I'll try without first.  
> \> \> \>   
> \> \>   
> \> \> Example code that reproduces it is a good idea. Also the full system specs. Does the crash produce any useable output, e.g., crash messages with stack traces etc.?  
> \> \>   
> \> \> -mario  
> \> \>  
> \>

---

<div class="post-metadata">

**Author:** ![mmortal03](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@mmortal03](https://psychtoolbox.discourse.group/u/mmortal03)\
**Post date:** [August 15, 2013, 12:11am UTC](https://psychtoolbox.discourse.group/t/screen-39-closeall-39-crashes-matlab-and-java/299/7 "2013-08-15T00:11:37Z")

</div>

For what it's worth, I tested this on a Nvidia Quadro 2000 machine (a.k.a. the crash-prone machine from the thread I referenced above), and I can't reproduce the crash. I do get one error line, if it matters:  
  
PsychImaging: GeometryCorrection: Spurious benign gl error [invalid operation] after computing postmap texture detected.  

  

Anyway, unless I'm doing it wrong, this rules out my idea that it's related to the other issue we've been seeing on 64-bit Windows.  

  
  

> On Wed, Aug 14, 2013 at 5:49 PM, Mario \<[mario.kleiner@...](mailto:mario.kleiner@...)\> wrote:  
> 
> > This sounds like an Intel graphics driver bug. Especially the Screen('Blendfunction') call. There's nothing in there that could cause this behaviour, except if the graphics driver has some weird bug - In which case there isn't really anything we could do.  
> >   
> > What happens if you leave PsychImaging('PrepareConfiguration/OpenWindow) calls in place and only remove the PsychImaging('AddTask', ...) statement? In that case it would behave like Screen('Openwindow',...); the only difference being that it executes some Java cleanup code on MS-Windows by calling PsychJavaSwingCleanup.m, something that is meant to prevent the infamous java.lang.outOfHeapSpace errors one sometimes sees on Windows with Matlab due to some Matlab Java bugs.  
> >   
> > What happens if you call Screen('Blendfunction', win, GL\_ONE, GL\_ZERO); before the Screen('CloseAll') or clear all call? This would restore alpha-blending to the original state before that function was used?  
> >   
> > I assume your Psychtoolbox is up to date?  
> > Do other demos with Screen('Blendfunction') work?  
> >   
> > You could try updating your graphics driver and hope for the best. In my experience, Intel gfx + MS-Windows == Trouble due to lots of driver bugs.  
> >   
> > -mario  
> >   
> > --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox%40yahoogroups.com), "qiagenmidikit" \<qiagenmidik
> > 
> >   
> > it@...\> wrote:  
> > \>  
> > \> OK a code example indeed makes things more clear: It seems now that the crash is connected to using PsychImaging (rather than Screen), combined with setting a BlendFunction, combined with Screen('CloseAll') and 'clear all'. The code below reliably causes matlab to crash for me (although without the effect on Java that I described above).  
> > \>   
> > \> If I open the window with Screen('OpenWindow') and remove all the PsychImaging calls, there is no crash.  
> > \>   
> > \> If I remove the BlendFunction call, there is no crash.  
> > \>   
> > \> If I remove the clear all at the end, there is also no crash (this is different from my real code where I first got that crash, because my real code does not contain a clear all).  
> > \>   
> > \> So this doesn't seem to have anything todo with the try/catch.  
> > \>   
> > \> There is no useful error output from matlab. It crashes hard and then does not show any report at the start of the next session.  
> > \>   
> > \> What system specs do you need?  
> > \> - ThinkPad X200 tablet  
> > \> - Intel Core 2 Duo  
> > \> - 8 GB RAM  
> > \> - 64-bit Windows 7  
> > \> - Dual monitor setup (internal + external).  
> > \>   
> > \> PTB-INFO: OpenGL-Renderer is Intel :: Mobile Intel(R) 4 Series Express Chipset Family :: 2.1.0 - Build 8.15.10.2302  
> > \> OpenGL-Vendor / renderer / version are: Intel - Mobile Intel(R) 4 Series Express Chipset Family - 2.1.0 - Build 8.15.10.2302  
> > \>   
> > \> OpenGL-Extensions are: GL\_EXT\_blend\_minmax GL\_EXT\_blend\_subtract GL\_EXT\_blend\_color GL\_EXT\_abgr GL\_EXT\_texture3D GL\_EXT\_clip\_volume\_hint GL\_EXT\_compiled\_vertex\_array GL\_SGIS\_texture\_edge\_clamp GL\_SGIS\_generate\_mipmap GL\_EXT\_draw\_range\_elements GL\_SGIS\_texture\_lod GL\_EXT\_rescale\_normal GL\_EXT\_packed\_pixels GL\_EXT\_texture\_edge\_clamp GL\_EXT\_separate\_specular\_color GL\_ARB\_multitexture GL\_EXT\_texture\_env\_combine GL\_EXT\_bgra GL\_EXT\_blend\_func\_separate GL\_EXT\_secondary\_color GL\_EXT\_fog\_coord GL\_EXT\_texture\_env\_add GL\_ARB\_texture\_cube\_map GL\_ARB\_transpose\_matrix GL\_ARB\_texture\_env\_add GL\_IBM\_texture\_mirrored\_repeat GL\_EXT\_multi\_draw\_arrays GL\_NV\_blend\_square GL\_ARB\_texture\_compression GL\_3DFX\_texture\_compression\_FXT1 GL\_EXT\_texture\_filter\_anisotropic GL\_ARB\_texture\_border\_clamp GL\_ARB\_point\_parameters GL\_ARB\_texture\_env\_combine GL\_ARB\_texture\_env\_dot3 GL\_ARB\_texture\_env\_crossbar GL\_EXT\_texture\_compression\_s3tc GL\_ARB\_shadow GL\_ARB\_window\_pos GL\_EXT\_shadow\_funcs GL\_EXT\_stencil\_wrap GL\_ARB\_vertex\_program GL\_EXT\_texture\_rectangle GL\_ARB\_fragment\_program GL\_EXT\_stencil\_two\_side GL\_ATI\_separate\_stencil GL\_ARB\_vertex\_buffer\_object GL\_EXT\_texture\_lod\_bias GL\_ARB\_occlusion\_query GL\_ARB\_fragment\_shader GL\_ARB\_shader\_objects GL\_ARB\_shading\_language\_100 GL\_ARB\_texture\_non\_power\_of\_two GL\_ARB\_vertex\_shader GL\_NV\_texgen\_reflection GL\_ARB\_point\_sprite GL\_EXT\_blend\_equation\_separate GL\_ARB\_depth\_texture GL\_ARB\_texture\_rectangle GL\_ARB\_draw\_buffers GL\_ARB\_color\_buffer\_float GL\_ARB\_half\_float\_pixel GL\_ARB\_texture\_float GL\_ARB\_pixel\_buffer\_object GL\_EXT\_framebuffer\_object GL\_ARB\_draw\_instanced GL\_ARB\_half\_float\_vertex GL\_EXT\_draw\_buffers2 GL\_WIN\_swap\_hint GL\_EXT\_texture\_sRGB GL\_EXT\_packed\_float GL\_EXT\_texture\_shared\_exponent GL\_ARB\_texture\_rg GL\_ARB\_texture\_compression\_rgtc GL\_NV\_conditional\_render GL\_EXT\_texture\_swizzle GL\_ARB\_framebuffer\_sRGB GL\_EXT\_packed\_depth\_stencil GL\_ARB\_depth\_buffer\_float GL\_EXT\_transform\_feedback GL\_EXT\_framebuffer\_blit GL\_ARB\_vertex\_array\_object   
> > \>   
> > \>   
> > \> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
> > \> % My code example:  
> > \>   
> > \> Screen('Preference', 'SkipSyncTests', 1);  
> > \>   
> > \> % win = Screen('OpenWindow', 1, 255/2);  
> > \> PsychImaging('PrepareConfiguration');  
> > \> PsychImaging('AddTask', 'AllViews', 'GeometryCorrection', 'D:\SkyDrive\Documents\MATLAB\lab\angleTask\undistortionConfigTest.mat');  
> > \> win = PsychImaging('OpenWindow', 1, 255/2);  
> > \>   
> > \> Screen('BlendFunction', win, GL\_SRC\_ALPHA, GL\_ONE\_MINUS\_SRC\_ALPHA);  
> > \>   
> > \> for i = 1:(2\*60)  
> > \> Screen('Flip', win);  
> > \> end  
> > \>   
> > \> Screen('CloseAll')  
> > \> clear all  
> > \>   
> > \> % Code example end  
> > \>   
> > 
> > \> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox%40yahoogroups.com), "Mario" \<mario.kleiner@\> wrote:  
> > \> \>  
> > \> \>   
> > \> \>   
> > \> \> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox%40yahoogroups.com), "qiagenmidikit" \<qiagenmidikit@\> wrote:  
> > \> \> \>  
> > \> \> \> Hi,  
> > \> \> \>   
> > \> \> \> I'm experiencing a weird crash when calling Screen('CloseAll') on Windows 7 64bit Matalb R2013a. The crash freezes Matlab and apparently also crashes Java, because Matlab won't start after such a crash until I reboot, unless I execute java.exe from my Start Menu.  
> > \> \> \>   
> > \> \> \> This happens in the following scenario:  
> > \> \> \>   
> > \> \> \> I use PTB to display some stimulus, including a geometric correction for cylindrical projection as described in DisplayUndistortionHalfCylinder.  
> > \> \> \>   
> > \> \> \> In my Matlab code, I wrap everything, starting from where the PTB window is opened, in a try...catch statement. To make debugging easier, the catch statement calls Screen('CloseAll') to close the screen before rethrowing the error.  
> > \> \> \>   
> > \> \> \> It seems that this Screen('CloseAll') in the catch statement causes the crash described above. If I remove it, there's no crash. When I call Screen('CloseAll') after exiting debug mode, there's also no crash.  
> > \> \> \>   
> > \> \>   
> > \> \> That's indeed weird. Our demos call Screen('CloseAll') all the time from the catch branch of try-catch and this doesn't cause crashes. We usually call sca; which does other cleanup work besides Screen('CloseAll').  
> > \> \>   
> > \> \> \> In all cases, the error causing the try...catch to trigger is something trivial in an unrelated part of code.  
> > \> \> \>   
> > \> \> \> I'm doing all this on my four year old laptop, which I use for development. Could it be that the crash is due to my old graphics hardware not being able to deal with the geometric undistortion or so?  
> > \> \> \>  
> > \> \>   
> > \> \> No. Of course one can not exclude the probability of odd graphics driver bugs, but in general pretty much any graphics card since around 2006/2007 should be able to do this without trouble.  
> > \> \>   
> > \> \> \> If you have an idea what the problem might be, that would be great. I could try to write a minimal code example but it would be quite some work, so I'll try without first.  
> > \> \> \>   
> > \> \>   
> > \> \> Example code that reproduces it is a good idea. Also the full system specs. Does the crash produce any useable output, e.g., crash messages with stack traces etc.?  
> > \> \>   
> > \> \> -mario  
> > \> \>  
> > \>
