MATLAB: Does the toolbox cache file keep changing in MATLAB 7.4 (R2007a)

MATLAB

Even though the installed toolboxes do not change, it looks like the toolbox cache file changes quite frequently, sometimes including subfiles inside directories and sometimes not. This is causing problems for some computing grid-distributed Matlab code that we are running, since multiple instances of Matlab are trying to read the same file, which keeps changing for no good reason.
On a related note, Matlab sometimes spinlocks on a call like this (strace output below):
[pid 2681] read(6, "", 32768) = 0
fid 6 == $HOME/.matlab/R2007a/toolbox_cache-7.4.0.158-3151539491-glnxa64.xml
read(2) returning 0 indicates EOF, so Matlab should not continue to try reading this file. This essentially causes Matlab to hang indefinitely. Here's the stack trace leading up to this:
#0 0x00000037ce8b92af in __read_nocancel () from /lib64/tls/libc.so.6
#1 0x00000037ce865262 in _IO_file_read_internal () from /lib64/tls/libc.so.6
#2 0x00000037ce86453d in _IO_new_file_underflow () from /lib64/tls/libc.so.6
#3 0x00000037ce86636e in _IO_default_uflow_internal ()
#4 0x00000037ce85bb5d in _IO_getline_info_internal ()
#5 0x00000037ce85a983 in fgets () from /lib64/tls/libc.so.6 vvv MATLAB CODE BELOW vvv
#6 0x0000002a97f04744 in mpRevertFromToolboxCache ()
#7 0x0000002a97f04978 in mpRevertFromToolboxCache ()
#8 0x0000002a97f04b4e in mpRevertFromToolboxCache ()
#9 0x0000002a97f04ef1 in mpUseToolboxCache ()
#10 0x0000002a96042f6f in mnSetLoginScriptName ()

Best Answer

It is possible that the toolbox path cache became corrupted. To remedy this issue, please take the following steps to force MATLAB to regenerate the preferences directory, which includes the toolbox path cache file:
1. Open MATLAB.
2. Enter 'prefdir' in the MATLAB command window.
3. Rename the directory returned by 'prefdir'. E.g., rename the '.../R2007a' directory to '.../R2007aold'.
4. Restart MATLAB and try running your program again.
If the above procedure does not resolve the issue, please try the following:
1. Open MATLAB.
2. Go to File -> Preferences -> General.
3. Uncheck the box next to 'Enable toolbox path cache'.
4. Click OK, restart MATLAB, and try running your program again.