[kepler-dev] [Ptolemy] Error reporting/threading issue in MoMLSimpleApplication

Christopher Brooks cxh at eecs.berkeley.edu
Fri May 1 13:03:24 PDT 2009


I modified moml.MoMLSimpleApplication so that we call
Manager.startRun() and now appropriately handle errors
from other threads.

Hopefully, this will not affect classes that extend
MoMLSimpleApplication, but it might as we construct
and start a thread in the constructor.

_Christopher

> On Fri, May 1, 2009 at 1:27 PM, Christopher Brooks <cxh at eecs.berkeley.edu>wrote:
> 
>> moml.MoMLSimpleApplication has an interesting bug.
>> Formerly, when running
>> cd $PTII/ptolemy/domains/pn/test
>> make
>>
>> There were two tests that were failing but not always being
>> reported by the test harness.
>>
>> The problem is that the test harness instantiates a
>> MoMLSimpleApplication and the MoMLSimpleApplication constructor
>> is what does the run.  However, the exception is thrown
>> in a separate thread and the constructor does not always
>> realize that there was an exception.
>>
>> The constructor looks like:
>>
>> public class MoMLSimpleApplication implements ChangeListener,
>> ExecutionListener {
>> ...
>>  public MoMLSimpleApplication(String xmlFileName) throws Throwable {
>> ...
>>        while (!_executionFinishedOrError) {
>>            Thread.yield();
>>        }
>>
>>        if (_sawThrowable != null) {
>>            throw _sawThrowable;
>>        }
>>    }
>> ...
>>   public void executionError(Manager manager, Throwable throwable) {
>>        _sawThrowable = throwable;
>>        _executionFinishedOrError = true;
>>        throw new RuntimeException("Execution error "
>>                + Thread.currentThread().getName(), throwable);
>>    }
>>
>> }
>>
>> What happens is that executionError() gets called by the Manager,
>> in a different thread, but the constructor does not always see
>> _sawThrowable being set to null.
>>
>> How should synchronization be added so that if executionError()
>> is called in a different thread that the constructor always sees
>> the changed value?
>>
>> _Christopher
>>
>> --
>> Christopher Brooks (cxh at eecs berkeley edu) University of California
>> CHESS Executive Director                      US Mail: 337 Cory Hall
>> Programmer/Analyst CHESS/Ptolemy/Trust        Berkeley, CA 94720-1774
>> ph: 510.643.9841 fax:510.642.2718             (Office: 545Q Cory)
>> home: (F-Tu) 707.665.0131 (W-F) 510.655.5480
>> _______________________________________________
>> Ptolemy maillist  -  Ptolemy at chess.eecs.berkeley.edu
>> http://chess.eecs.berkeley.edu/ptolemy/listinfo/ptolemy
>>
> 

-- 
Christopher Brooks (cxh at eecs berkeley edu) University of California
CHESS Executive Director                      US Mail: 337 Cory Hall
Programmer/Analyst CHESS/Ptolemy/Trust        Berkeley, CA 94720-1774
ph: 510.643.9841 fax:510.642.2718	      (Office: 545Q Cory)
home: (F-Tu) 707.665.0131 (W-F) 510.655.5480


More information about the Kepler-dev mailing list