Thanks, hopefully that solves it! I've got a pretty good solution currently. It requires no Julia code and seems pretty fast. My favourite part is that the Julia workspace persists across calls, through some sort of MEX magic that I don't fully understand. The one downside is that it requires all input data to be copied (MATLAB will segfault if you don't; I had the same problem in my MEX PostgreSQL wrapper). I'll check with work next week--I expect it to be pretty much done then--whether I can post this as a public repo. I am optimistic.
Overall I love the Julia API! My only complaints are being fixed by Jeff's latest PR :) On Wednesday, 4 March 2015 06:06:19 UTC-6, Tim Holy wrote: > > It seems possible we should add a second "boolean" argument to _julia_init > (in > init.c) that controls whether the signal handlers get set. But as a > workaround: > > http://stackoverflow.com/questions/9495113/how-to-get-the-handlers-name-address-for-some-signals-e-g-sigint-in-postgres > > > You could at least test whether that solves the problem, and then if so > perhaps it would be worth opening an issue in julia about whether we need > a > better solution. > > BTW, I'm interested in this topic too; see also > https://groups.google.com/d/msg/julia-users/dP_J5KilsEs/4CIERQ14vdgJ. We > should collaborate on a single solution (and it sounds like you're farther > along and perhaps more invested). I'm happy to pitch in if code gets > posted > somewhere. > > --Tim > > On Tuesday, March 03, 2015 09:18:04 PM Eric Davies wrote: > > Hi all, > > > > I'm attempting to embed julia in a MATLAB MEX file. Everything is going > > great, but MATLAB will sometimes segfault after having run some code > > calling Julia.* I believe I have narrowed it down to this > > issue: http://ubuntuforums.org/showthread.php?t=2093057 . Basically, I > > believe Julia is registering a SIGSEGV (or maybe other signal?) handler > > that overwrites the default for the JVM set by MATLAB. after the Julia > > function is done, that memory is freed. Then a segfault (or maybe other > > signal?) happens in the JVM and it tries to call Julia's handler but > > segfaults (again) as it is no longer there. > > > > Can anyone help me find a workaround? Perhaps if there's a way to > > "deregister" the handler, or if someone knows a way to get the current > > handler (before calling into Julia) and then setting it back to that > after > > Julia is done. > > > > I've never dealt with signals in C before so I apologize if I'm > describing > > things incorrectly or missing something. > > > > Thanks, > > Eric > > > > *I am able to reliably reproduce this by running any MEX function > linking > > to Julia and calling jl_init, then calling `help clear` in MATLAB. > > > > P.S.: I'm on Mac OS X 10.10 with MATLAB R2012b and Julia > v0.3.6/v0.4.0-dev > >
