Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Reliable freeze/crash on editing GUIs

Subject: Reliable freeze/crash on editing GUIs

From: Sven

Date: 5 Apr, 2013 17:33:19

Message: 1 of 4

Hi all, this small function below reliably crashes MATLAB (freeze and windows says program not responding).

function canCrashMatlab()
h = createInterface();
imageTypes = struct('name',{'slice','xray'},'scrollVal',{0,0});
imTypeNo = 1;
%uncommentThisToCrashMATLAB = [];
    function onScroll()
        %uncommentThisToCrashMATLAB=5
        if strcmp(imageTypes(imTypeNo).name,'slice')
        end
        thisFunctionCallWillErrorNormally();
    end
    function gui = createInterface()
        gui.Window = figure('WindowScrollWheelFcn',@(src,evnt)onScroll());
        gui.mainImH = imagesc(imread('rice.png'),'Parent',axes('Parent',gui.Window));
    end
end


The steps to recreate the crash are:

1. Run the function... it open's a window (scrolling will throw a normal error as expected)
2. Leave the window open, uncomment the 2 lines in the editor.
3. Scroll again.

Basically it seems that if I change-and-save a function called by a GUI while that GUI is open, then I perform the action in the GUI that would call that function, MATLAB dies horribly. I understand that changing the scope variables of an already-in-place GUI will be troublesome, but dumping to the desktop seems a bit of overkill.

Can anybody confirm that this happens to them too? My system is Win7, 2013a. Save all your work of course before trying.

Subject: Reliable freeze/crash on editing GUIs

From: Yair Altman

Date: 6 Apr, 2013 17:57:09

Message: 2 of 4

"Sven " <svendotholcombe@gmaildot.com> wrote in message <kjn1sv$shc$1@newscl01ah.mathworks.com>...
> Hi all, this small function below reliably crashes MATLAB (freeze and windows says program not responding).
[snip]

Sounds to me like something to report to <support@mathworks.com>...

Yair Altman
http://UndocumentedMatlab.com
 

Subject: Reliable freeze/crash on editing GUIs

From: Steven_Lord

Date: 10 Apr, 2013 19:26:39

Message: 3 of 4



"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message
news:kjpnll$mc1$1@newscl01ah.mathworks.com...
> "Sven " <svendotholcombe@gmaildot.com> wrote in message
> <kjn1sv$shc$1@newscl01ah.mathworks.com>...
>> Hi all, this small function below reliably crashes MATLAB (freeze and
>> windows says program not responding).
> [snip]
>
> Sounds to me like something to report to <support@mathworks.com>...

I agree with Yair. Please report this to support@mathworks.com for further
investigation.

Taking a look at the code, introducing a new variable into the definition of
a nested function and having that new variable cause some sort of "linkage"
between the function and the one in which it's nested seems like a Bad Idea
once there's already a function handle to that nested function. However,
doing that should not cause MATLAB to crash.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Reliable freeze/crash on editing GUIs

From: Sven

Date: 11 Apr, 2013 00:48:08

Message: 4 of 4

"Steven_Lord" <slord@mathworks.com> wrote in message <kk4edf$6aj$1@newscl01ah.mathworks.com>...
>
>
> "Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message
> news:kjpnll$mc1$1@newscl01ah.mathworks.com...
> > "Sven " <svendotholcombe@gmaildot.com> wrote in message
> > <kjn1sv$shc$1@newscl01ah.mathworks.com>...
> >> Hi all, this small function below reliably crashes MATLAB (freeze and
> >> windows says program not responding).
> > [snip]
> >
> > Sounds to me like something to report to <support@mathworks.com>...
>
> I agree with Yair. Please report this to support@mathworks.com for further
> investigation.
>
> Taking a look at the code, introducing a new variable into the definition of
> a nested function and having that new variable cause some sort of "linkage"
> between the function and the one in which it's nested seems like a Bad Idea
> once there's already a function handle to that nested function. However,
> doing that should not cause MATLAB to crash.

Yep, bug reported (1-MAI9W5) - I just wanted confirmation that it could be reproduced by someone else.

It's impossible for MATLAB to detect the "expected behaviour" in these cases, but crashing to desktop makes me "edit on eggshells", closing and re-opening a GUI whenever I make an edit (which is quite tedious if the callback you're trying to debug needs time/effort to set up). I'd much rather MATLAB detected this situation and spat an error out (like it does when you try to add variables to a static workspace during debugging).

For anyone hitting the same problem, here's some more info via Mathworks representatives:
When I try to distill the supplied code further, I have found that to consistently crash MATLAB, a shared scalar and a shared structure variables seem to be required. Additionally, the structure variable has to be used either in the condition or the body of an IF statement. Changing the scope of the shared scalar with the GUI window open will then almost for sure crashes MATLAB. Unfortunately, I suspect this is not the only condition that crashes MATLAB and I can only suggest you to always close the GUI window when editing the code.

Thanks,
Sven.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us