Comments (6)
I've also had occasionally crashing when using the call_matlab
function. I don't know if this is occurs due to a limitation imposed on MEX files by MATLAB or due to improper data handling on the Julia side and I haven't been able to pinpoint the root cause of this issue. For not being very large, this package is quite complicated since it deals with two higher level languages and their respective lower level interfaces. I've often thought it would be nice to have someone who is an expert in MEX files and/or embedding Julia take a look at this package. I don't consider myself to be an expert in either.
As a workaround, try to replace all instances of call_matlab
with equivalent calls to MATLAB using MATLAB.jl. The downside of this approach is that it limits the code you can call to what is available to the MATLAB engine session created by MATLAB.jl. Hopefully this works for your application.
from mex.jl.
Well the attached project is primarily a test on the stability of mex.jl, on a fork that was made quite a while ago. Honestly if the issue is only in the call_matlab function, then everything I really need for my actual purposes already works! I will experiment a bit with some tests that do not work with call_matlab.
Though if the issue is really only there, and probably being a GC issue - seeing how sporadic the crashes are - I can even try to create a minimal working(crashing) example. I won't have time for the coming 3 weeks, but if I have anything I will try to propose a fix or at the very least post it somewhere hereabouts!
In any case thanks a lot for updates to this package!
from mex.jl.
ok the easiest crash I can find is:
jl.eval('invalidsyntax()')
jl.eval('GC.gc()')
this is perhaps not very important, but pretty much any error you make in julia will later on lead to an unexpected crash when garbage collection triggers.
A totally unrelated minimal example is this:
function test(args::Vector{MATLAB.MxArray})
out = jvalue(args[3])
temp = args[2];
for i in 1:out
temp = call_matlab(1,"feval",[args[1],temp])
GC.gc()
end
temp
end
jl.mex('test',@(x) x*x,rand(5),1)
will run without any problems, even when called multiple times. However this
jl.mex('test',@(x) x*x,rand(5),2)
immediately comes crumbling to the ground.
from mex.jl.
from mex.jl.
I feel rather silly, as the second example is actually also an error.
temp = call_matlab(1,"feval",[args[1],temp])
call_matlab will return a vector, which gets put into temp. temp then gets again given to call_matlab, which is where it goes wrong.
it should've been
temp = call_matlab(1,"feval",[args[1],temp])[1]
which works just fine?
So then, it mostly seems that julia errors in mexed calls or matlab errors in callbacks will lead to some invalid memory somewhere and then crashes later on.
from mex.jl.
I tried to dig into this, but can't figure out where the issue is. It seems to just affect the call_matlab
function though. The simplest example I can find is
jleval call_matlab(1, "sin", 1.0)
Note that this function doesn't error, but this does cause a segmentation fault when MATLAB is closed (which can be seen if MATLAB is run from the terminal). Unfortunately, I don't really have the time to look into this any further.
from mex.jl.
Related Issues (12)
- Issues on Windows 10 [SOLVED] HOT 2
- Xcode build error when using mex
- Matlab closes quickly after executing mexjulia HOT 4
- Register v0.1.0 HOT 5
- TagBot trigger issue HOT 13
- Crashes in tight loops
- Pkg.test() fails HOT 4
- CI with Julia 1.8 fails HOT 1
- Release v0.1.1 HOT 1
- MEX.jl with Julia 1.10.1
- DLLs load improperly under 2021b in Windows 10/11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mex.jl.