# MEX file access violation

**URL:** <https://psychtoolbox.discourse.group/t/mex-file-access-violation/1338>\
**Category:** Uncategorized\
**Created:** [August 11, 2015, 4:39pm UTC](https://psychtoolbox.discourse.group/t/mex-file-access-violation/1338 "2015-08-11T16:39:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lauracd27](https://avatars.discourse-cdn.com/v4/letter/l/8797f3/32.png) [@lauracd27](https://psychtoolbox.discourse.group/u/lauracd27)\
**Post date:** [August 11, 2015, 4:39pm UTC](https://psychtoolbox.discourse.group/t/mex-file-access-violation/1338/1 "2015-08-11T16:39:25Z")

</div>

Any help would be very gratefully received!  
  
I am running a script using PTB (on Windows) which loops through and displays sequences of videos, but every so often Matlab will encounter an internal error and need to close. There is no particular point at which this occurs, it seems random. I can restart my computer, run the script 10 times and it'll crash on the 11th time. Or it'll crash first time. It also doesn't crash at the same point during my script - I loop through 12 blocks and it can crash at any time.  
  
When running in no java mode using the Windows command prompt (-nojvm) this crashing does not seem to occur, but it rotates my vidoes 90 degrees and I can't work out how to fix this. Also I can't run one script I need as the no java mode doesn't support the GetKey.m function, which I need.  
  
  
When crashing, it gives me this message:  

&nbsp;---------------------------------------------------------------------------------------------------------------------------

Abnormal termination:

Access violation

&nbsp;

Register State (from fault):

&nbsp; EAX = 00000002&nbsp; EBX = 32767579

&nbsp; ECX = 23a27630&nbsp; EDX = 32767579

&nbsp; ESP = 00c262c0&nbsp; EBP = 00000000

&nbsp; ESI = 00c26344&nbsp; EDI = 00c262f4

&nbsp;

&nbsp; EIP = 332c9e4c&nbsp; EFL = 00010287

&nbsp;

&nbsp;&nbsp; CS = 00000023&nbsp;&nbsp; DS = 0000002b&nbsp;&nbsp; SS = 0000002b

&nbsp;&nbsp; ES = 0000002b&nbsp;&nbsp; FS = 00000053&nbsp;&nbsp; GS = 0000002b

&nbsp;

Stack Trace (from fault):

&nbsp;

&nbsp;

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.

---------------------------------------------------------------------------------------------------------------------------  
The only MEX files I am using are Screen and WaitSecs.mexw32, and the MatLab file reqmgt.mexw32. I have disabled WaitSecs, and still get the crashing, so I am assuming the problem is Screen.  
  
I am having to use 32bit Matlab, with Psychtoolbox-3.0.11, as that's all I can get to work with gstreamer-1.4.  
  
Any ideas?
