This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TI Debug Server bug in debugSession.terminate() causes Matlab crash

Other Parts Discussed in Thread: CCSTUDIO

There is a serious, but intermittent, crash in Matlab when closing out a TI Debug Server session.  The crash follows a call to the debug session terminate() function by a few seconds.  The crash will not occur if a target.connect() has not been called in between the openSession and terminate.  The frequency of the crash seems to vary by PC (though all appear to have identical CCS and Debug Server versions) from about 5% to 20%.  Most PCs are Matlab R2010a, though one was R2008.   The nature of the crash is that the Matlab app, and the entire Matlab workspace immediately dissappear.  There is no Matlab crash report, nor any indication of a previous crash upon re-starting Matlab.  If Matlab and the app are re-started following a crash, the test will then execute at its normal rate of failure without any reset of hardware or USB connections, i.e it will then succeed or crash with no lingering effects from the previous crash.

The OS on PCs is WinXP, SP3 and one with Win XP, SP2. 

The CCS and Java versions on the PCs are:

CCS v 4.2.3.0004
java.version=1.5.0_14
 
Matlab 7.10.0 (R2010a)
Java 1.6.0_12-b04 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode
 
Workaround:
I have a work-around which is simply to create static/global instances of the debugServer and the debugSessions, and to never call debugSession.terminate(), even when the app is being closed.
 
If anybody cares, I can provide a desktop recording showing Matlab execution and crash; however, they are large AVI files (150MB).
 
ML
 
 
*********
HW configuration to reproduce failure:
 
1).   TI C6472 EVM from eInfoChips, plus a Spectrum Digital JTAG debugger, XDS560v2 STM (USB).  Note:  the crash has occured on multiple EVMs, and with several JTAG debuggers, including XDS 510 USB and the Blackhawk BH560M (USB). 
 
SW configuration to reproduce failure:
 
2).  To configure Matlab: add the following to the end of Matlab's classpath.txt (e.g. C:\Program Files\MATLAB\R2010a\toolbox\local\classpath.txt):
C:/Program Files/Texas Instruments/ccsv4/DebugServer/packages/ti/dss/java/js.jar
C:/Program Files/Texas Instruments/ccsv4/DebugServer/packages/ti/dss/java/dss.jar
C:/Program Files/Texas Instruments/ccsv4/DebugServer/packages/ti/dss/java/com.ti.debug.engine_1.0.0.jar
C:/Program Files/Texas Instruments/ccsv4/DebugServer/packages/ti/dss/java/com.ti.ccstudio.scripting.environment_3.1.0.jar
C:/Program Files/Texas Instruments/ccsv4/DebugServerpackages/ti/dss/java/com.ti.ccstudio.scripting.rtdx_1.0.0.jar
C:/Program Files/Texas Instruments/ccsv4/eclipse/startup.jar
 
I use a GUI app developed in Matlab (GUIDE) with a button that calls the runFailTest() code shown below.
 
3).  CCS: install CCS 4.2.3.00004 (see attached CCS version info, 'CCS_cfgDetails.txt').
 
4).  Use the default CCXML script that is installed with the XDS560v2 Spectrum Digital debugger (e.g. 'EVM6472_XDS560v2USB.ccxml').  This target config has core 0 using  ..\emulation\boards\evmc6472\gel\evmc6472.gel, and cores 1-5 using evmc6472-MemoryMap.gel.

**********

This is from TI DS API documentation (Class DebugServer) showing how to use open / close a debug session:

// Create Environment and open a debug session
ScriptingEnvironment env = new ScriptingEnvironment();
DebugServer myServer = (DebugServer) env.getServer("DebugServer.1");
DebugSession mySession = myServer.openSession("*", "*");

...

// Terminate our session and stop the server
mySession.terminate()
myServer.stop()

 

 


**********

Here is the Matlab function that exposes the (intermittent) crash:


function runFailTest()
 
import com.ti.ccstudio.scripting.environment.*;
import com.ti.debug.engine.scripting.*;
import java.lang.System;
import java.lang.Object;
 
System.setProperty('XPCOM.RUNTIME', 'C:\Program Files\Texas Instruments\ccsv4\DebugServer\win32' );
 
script = ScriptingEnvironment.instance();
script.setScriptTimeout(60000);
script.traceSetConsoleLevel(TraceLevel.ALL); %% see all messages at Matlab console
 
uDebugServer = script.getServer('DebugServer.1');
uDebugServer.setConfig( 'C:\Documents and Settings\mlogan\user\CCSTargetConfigurations\EVM6472_XDS560v2USB.ccxml' );
 
debugSessionCore1 = uDebugServer.openSession('*', '*');
 
debugSessionCore1.target.connect();
    
pause(2);
    
debugSessionCore1.target.disconnect();
   
debugSessionCore1.terminate();  %% crash occurs here (but only if target.connect/disconnect called prior)
    
uDebugServer.stop();

 

  • Hello Michael,

    If you remove the debugSession.terminate() call, will it still crash on the debugServer.stop() call? I would expect it to do so but just want to confirm this behavior.

    Also I assume DSS continues on normally when Matlab crashes.

    Thanks

    ki

  • Ki-Soo Lee said:

    Hello Michael,

    If you remove the debugSession.terminate() call, will it still crash on the debugServer.stop() call? I would expect it to do so but just want to confirm this behavior.

    >> Perhaps -- I'll check. 

     

    Also I assume DSS continues on normally when Matlab crashes.

    >>  how would I check that?

     

    Thanks

    ki

     

  • If DSS encountered an error or crashed, it would send error messages to the console. You can also generate a verbose DSS log and see if there were any errors in the log.

  • Well, the console in this case is Matlab -- which gets vaporized so I obviously I don't see any messages.  My Matlab app does set an XML log file with verbose setting, and I don't see any error messages.  Since I have called debugSession.terminate and debugServer.stop, I don't really expect debug server to still be running anyway.  So, when you say it should continue normally -- I don't know how to determine that.  

  • Michael Logan said:
    My Matlab app does set an XML log file with verbose setting, and I don't see any error messages.

    Then it probably executed successfully.

    If the terminate or stop call threw an exception, it would be in the logs. What I meant by "continue normally" is if any actions after the debugServer.stop() call got executed.

     

  • I can't say one way or the other, since my whole application gets vaporized after the debugSession.terminate, but before the debugServer.stop.

    ML

     

  • Ah, I keep forgetting that everything is running from Matlab. Sorry. Does it still crash when you remove the terminate call?

  • No.  I remove the debugSession.terminate call (and also the debugServer.stop) and I don't have any more crashes.

    ML

     

  • Michael Logan said:

    Hello Michael,

    If you remove the debugSession.terminate() call, will it still crash on the debugServer.stop() call? I would expect it to do so but just want to confirm this behavior.

    >> Perhaps -- I'll check. 

    You are correct: I verified that if the debugSession.terminate() is removed, then it will crash on debugServer.stop() if that is still called.

     

     

    Also I assume DSS continues on normally when Matlab crashes.

    >>  how would I check that?

     

    Thanks

    ki

     

    [/quote]

     

  • Any updates?  Is this a confirmed bug in Debug Server?

  • Has a bug report been filed?

    Cheers

  • Sorry, no update or bug report yet. It is unknown if the issue is with DSS or Matlab. CCSv4/DSS integration with Matlab is not officially supported so I'm not sure what I can do here.

    Sorry.

    ki

  • Ki-Soo Lee said:

    Sorry, no update or bug report yet. It is unknown if the issue is with DSS or Matlab. CCSv4/DSS integration with Matlab is not officially supported so I'm not sure what I can do here.

    Sorry.

    ki

    Is there a newer version of DSS (e.g. CCSv5) that is supported with Matlab?  If so, does it have the problem?

    ML

     

  • This link details what the current level of support there is with Matlab and CCSv4 (and v5)

    http://www.mathworks.com/support/solutions/en/data/1-DM9192/

    ki

  • Ki-Soo Lee said:

    This link details what the current level of support there is with Matlab and CCSv4 (and v5)

    http://www.mathworks.com/support/solutions/en/data/1-DM9192/

    ki

     

    Hmm...the link you provided seems to contradict your statement that "CCSv4/DSS integration with Matlab is not officially supported"...

    the Mathworks link above says only  "You can use TI’s DSS scripting with CCS 4.0 to load and run the embedded software on supported TI processors."

    It makes no mention of CCSv5.  

    ML


  • Michael Logan said:
    Hmm...the link you provided seems to contradict your statement that "CCSv4/DSS integration with Matlab is not officially supported"...

    I should have probably just said DSS integration with Matlab is not supported. The extent of the existing support revolves around generating makefile based projects that can be built within the CCS environment. But this thread has been about interfacing with the CCS debugger directly from within the Matlab environment and that is not supported.

    Michael Logan said:
    the Mathworks link above says only  "You can use TI’s DSS scripting with CCS 4.0 to load and run the embedded software on supported TI processors."

    Yes, they recommend using DSS. I would also recommend using DSS standalone.

    Michael Logan said:
    It makes no mention of CCSv5.  

    There are no plans I am aware of where anything will change in v5. But it would be best to contact Mathworks directly for confirmation.

  • Ki-Soo Lee said:

    Hmm...the link you provided seems to contradict your statement that "CCSv4/DSS integration with Matlab is not officially supported"...

    I should have probably just said DSS integration with Matlab is not supported. The extent of the existing support revolves around generating makefile based projects that can be built within the CCS environment. But this thread has been about interfacing with the CCS debugger directly from within the Matlab environment and that is not supported.

    Michael Logan said:
    the Mathworks link above says only  "You can use TI’s DSS scripting with CCS 4.0 to load and run the embedded software on supported TI processors."

    Yes, they recommend using DSS. I would also recommend using DSS standalone.

    Michael Logan said:
    It makes no mention of CCSv5.  

    There are no plans I am aware of where anything will change in v5. But it would be best to contact Mathworks directly for confirmation.

    [/quote]

     

    I think I was mixing terminology a bit -- I was interpreting DSS integration with Matlab to mean being able to access the Debug Server Java objects.  In any case, using DSS outside of Matlab is not worth anything to us, the whole point is to link the two together for our test purpose.  

    I guess we've come full circle -- I will re-iterate what our current status is:  Matlab + CCS Debug Server accessed via Java objects if fully integrated and working successfully for us, with only  the one exception: debugSession.terminate() causes Matlab to crash intermittently.  Clearly there is some kind of un-handled event/exception.  It probably could be fixed on either end---I'm just sort of surprised that neither TI nor Mathworks is interested in doing so.  For now, our work-around is that we just don't call the terminte() function -- since I haven't seen any big memory leaks, I'm satisfied with that.

    Thanks for your input,

    ML

  • Michael Logan said:
    Matlab + CCS Debug Server accessed via Java objects if fully integrated and working successfully for us, with only  the one exception: debugSession.terminate() causes Matlab to crash intermittently.  Clearly there is some kind of un-handled event/exception.

    If the terminate or stop call is throwing an exception, you can catch the exception so that the script will not prematurely terminate and cause Matlab to crash (if the DSS exception is indeed what is causing Matlab to crash). If no exception is being thrown, then DSS is working fine.

    Michael Logan said:
    It probably could be fixed on either end---I'm just sort of surprised that neither TI nor Mathworks is interested in doing so.

    We do not have the expertise to properly debug issues with Matlab hence why we do not have many suggestions when there is a problem with it. Sorry.

    ki