[kepler-dev] questions about matlab actor in snow leopard.

Jianwu Wang jianwu at sdsc.edu
Tue Apr 27 09:28:16 PDT 2010


Hi Christopher,

     Thanks for your info. I'll have a check.

     The simplest way is to do not free output_buf if 
malloc_size(output_buf) is 0. It's definitely not the best solution though.

Best wishes

Sincerely yours

Jianwu Wang
jianwu at sdsc.edu
http://users.sdsc.edu/~jianwu/

Scientific Workflow Automation Technologies (SWAT) Laboratory
San Diego Supercomputer Center
University of California, San Diego
San Diego, CA, U.S.A.


On 4/26/2010 5:50 PM, Christopher Brooks wrote:
> Hi Jianwu,
> The free could be superfluous.  It would be interesting to
> try this code using electric fence or valgrind, but I'm not sure
> how well those work with JNI.
>
> The ptmatlab code is fairly old, if you get a fix, feel free to check
> it in.
>
> _Christopher
>
> On 4/26/10 5:29 PM, Jianwu Wang wrote:
>> Hi Christopher,
>>
>> Thanks for your quick update. It works for me. I replaced the
>> $Kepler/common/lib/ptolemy/matlab/libptmatlab.dylib by the new generated
>> libptmatlab.jnilib in $PTII/ptolemy/ptolemy/makefile directory and
>> tested the $Kepler/outreach/resources/demos/Matlab/MatlabExpression.xml.
>> The workflow was running well. But the whole Kepler crashed when I tried
>> to stop the execution.
>>
>> A pop up window shows that 'Kepler quit unexpectedly while using the
>> libptmatlab.jnilib plugin.' Its detailed message shows that:
>>
>> Thread 30 Crashed: Java: MatlabExpression-debug
>> 0 libSystem.B.dylib 0x00007fff8557e01e __semwait_signal_nocancel + 10
>> 1 libSystem.B.dylib 0x00007fff8557df20 nanosleep$NOCANCEL + 129
>> 2 libSystem.B.dylib 0x00007fff855da902 usleep$NOCANCEL + 57
>> 3 libSystem.B.dylib 0x00007fff855f9eb8 abort + 93
>> 4 libSystem.B.dylib 0x00007fff85511a75 free + 128
>> 5 libptmatlab.jnilib 0x000000012f6788f8
>> Java_ptolemy_matlab_Engine_ptmatlabEngClose + 170
>>
>>
>> Dan and I dug it a little bit, and found out it is because of the
>> sentence 162 in ptmatlab.cc : 'free(output_buf);'. We tested the
>> malloc_size(output_buf) function before free() function, and it returned
>> 0. The console message shows that:
>>
>> [run] ptmatlabCreateDoubleMatrix(input) 25 x 25
>> [run] ptmatlabDestroy(input)
>> [run] matlabEngine.evalString("surf(input)")
>> [run] matlabEngine.close(5638846816)
>> [run] ptmatlabEngClose: calling engClose(1343879520)
>> [run] java(49363,0x14e000000) malloc: *** error for object 0xde5600:
>> pointer being freed was not allocated
>> [run] *** set a breakpoint in malloc_error_break to debug
>> [run] ptmatlabEngClose: freeing 0xde5600
>>
>>
>> I remember I also met the console message when I using 32 bit leopard
>> with 64bit Matlab and Java 1.6 64 bit. But Kepler doesn't crash at
>> leopard. Do you have any idea about it? Thanks a lot!
>>
>> Christopher Brooks wrote:
>>> Hi Jianwu,
>>> I just updated $PTII/ptolemy/ptolemy/makefile so that it will build
>>> either
>>> * 32bit
>>> * 64bit
>>> * Universal (32bit and 64bit).
>>>
>>> If you have a chance, please update your tree and rerun "make".
>>>
>>> Thanks,
>>>
>>> _Christopher
>>>
>>> On 4/26/10 4:01 PM, Jianwu Wang wrote:
>>>> Hi Chistopher,
>>>>
>>>> My machine is snow leopard (10.6.3, 64 bit), matlab 2009b 64 bit, Java
>>>> 1.6 64 bit. I tried to use 'make' command in ptII/ptolemy/matlab
>>>> directory to generate libptmatlab file. But it has the following 
>>>> error.
>>>> I think it is because my matlab installation do not have maci 
>>>> directory,
>>>> only have maci64 directory. Do you think the problem is because of my
>>>> installation or make file? Thanks.
>>>>
>>>> echo $DYLD_LIBRARY_PATH
>>>> /Applications/MATLAB64/MATLAB_R2009b/MATLAB_R2009b.app/bin/maci64:/Applications/MATLAB64/MATLAB_R2009b/MATLAB_R2009b.app/sys/os/maci64 
>>>>
>>>>
>>>>
>>>>
>>>> kepler:matlab jianwu$ make
>>>> if [ "`uname -s`" = "Darwin" ]; then \
>>>> make libptmatlabUniversal.jnilib; \
>>>> mv libptmatlabUniversal.jnilib libptmatlab.jnilib; \
>>>> file libptmatlab.jnilib; \
>>>> else \
>>>> CLASSPATH="../.."
>>>> "/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin/javah" 
>>>>
>>>>
>>>> -jni -o ptmatlab.h ptolemy.matlab.Engine; \
>>>> "/usr/bin/gcc" -DPT_NO_ENGGETARRAY -DPT_NO_ENGPUTARRAY
>>>> -DPT_NO_MXGETNAME \
>>>> "-I/Applications/MATLAB64/MATLAB_R2009b/MATLAB_R2009b.app/extern/include" 
>>>>
>>>> \
>>>> "-I/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/../Headers" 
>>>>
>>>>
>>>> \
>>>> "-I/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/../include/darwin" 
>>>>
>>>>
>>>> \
>>>> ptmatlab.cc -fno-exceptions -dynamiclib -o libptmatlab32.jnilib
>>>> -L"/Applications/MATLAB64/MATLAB_R2009b/MATLAB_R2009b.app/bin/maci"
>>>> -leng -lmx -lmex; \
>>>> fi
>>>> CLASSPATH="../.."
>>>> "/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin/javah" 
>>>>
>>>>
>>>> -jni -o ptmatlab.h ptolemy.matlab.Engine
>>>> "/usr/bin/gcc" -DPT_NO_ENGGETARRAY -DPT_NO_ENGPUTARRAY
>>>> -DPT_NO_MXGETNAME \
>>>> "-I/Applications/MATLAB64/MATLAB_R2009b/MATLAB_R2009b.app/extern/include" 
>>>>
>>>> \
>>>> "-I/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/../Headers" 
>>>>
>>>>
>>>> \
>>>> "-I/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/../include/darwin" 
>>>>
>>>>
>>>> \
>>>> ptmatlab.cc -fno-exceptions -dynamiclib -o libptmatlab32.jnilib
>>>> -L"/Applications/MATLAB64/MATLAB_R2009b/MATLAB_R2009b.app/bin/maci"
>>>> -leng -lmx -lmex
>>>> ld: warning: directory
>>>> '/Applications/MATLAB64/MATLAB_R2009b/MATLAB_R2009b.app/bin/maci'
>>>> following -L not found
>>>> ld: library not found for -leng
>>>> collect2: ld returned 1 exit status
>>>> make[1]: *** [libptmatlab32.jnilib] Error 1
>>>> mv: rename libptmatlabUniversal.jnilib to libptmatlab.jnilib: No such
>>>> file or directory
>>>> libptmatlab.jnilib: cannot open `libptmatlab.jnilib' (No such file or
>>>> directory)
>>>>
>>>
>>
>>
>


More information about the Kepler-dev mailing list