[kepler-dev] fix for ptolemy matlab actor

ian.brown@hsbcib.com ian.brown at hsbcib.com
Wed Jan 16 05:46:20 PST 2008

I've just started using the ptolemy matlab expression actor 
(ptolemy.matlab.Expression) and I was finding the problem that multiple 
runs would cause a crash.
You could always run a model once but if you invoked it a second time 
without restarting ptolemy (i.e. press run, stop, run, stop) it would 
crash when stopping the second run.
I tracked down the issue to ptmatlab.cc in the routine 
Java_ptolemy_matlab_Engine_ptmatlabEngClose. It was deleting the output 
buffer before closing the matlab engine and without letting the matlab 
engine know not to use it. A solution would be to either call 
engOutputBuffer(ep, NULL, 0) before destroying the memory, or to simply 
delay destroying the memory until after the matlab engine instance is 
closed. I chose the latter and now I can run it fine without any crashes.

I have attached my version of ptmatlab.cc. It has this change plus a few 
fflush(stdout) statements after the logging printfs. This is important as 
without them the java and the C log will use different buffers and you 
cannot verify the correct calling order.


HSBC Bank plc may be solicited in the course of its placement efforts for 
a new issue, by investment clients of the firm for whom the Bank as a firm 
already provides other services. It may equally decide to allocate to its 
own proprietary book or with an associate of HSBC Group. This represents a 
potential conflict of interest. HSBC Bank plc has internal arrangements 
designed to ensure that the firm would give unbiased and full advice to 
the corporate finance client about the valuation and pricing of the 
offering as well as internal systems, controls and procedures to identify 
and manage conflicts of interest.

HSBC Bank plc
Registered Office: 8 Canada Square, London E14 5HQ, United Kingdom
Registered in England - Number 14259
Authorised and regulated by the Financial Services Authority.


This transmission has been issued by a member of the HSBC Group
"HSBC" for the information of the addressee only and should not be
reproduced and/or distributed to any other person. Each page
attached hereto must be read in conjunction with any disclaimer
which forms part of it. Unless otherwise stated, this transmission
is neither an offer nor the solicitation of an offer to sell or
purchase any investment. Its contents are based on information
obtained from sources believed to be reliable but HSBC makes no
representation and accepts no responsibility or liability as to its
completeness or accuracy.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mercury.nceas.ucsb.edu/ecoinformatics/pipermail/kepler-dev/attachments/20080116/7bc967b1/attachment-0001.htm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ptmatlab.cc
Type: application/octet-stream
Size: 24809 bytes
Desc: not available
Url : http://mercury.nceas.ucsb.edu/ecoinformatics/pipermail/kepler-dev/attachments/20080116/7bc967b1/ptmatlab-0001.obj

More information about the Kepler-dev mailing list