Boost logo

Boost Users :

Subject: Re: [Boost-users] [Thread] code segfaults/hangs when being called from matlab, not when run standalone
From: Dougal Sutherland (dougal_at_[hidden])
Date: 2012-01-30 23:33:51

On Mon, Jan 30, 2012 at 1:21 PM, Dougal Sutherland <dougal_at_[hidden]> wrote:

> I have some code using boost::thread that works fine when it's called
> directly from a main() function, but (almost) always segfaults and/or hangs
> forever when called from a Matlab mex interface. I don't know whether
> that's due to the Matlab interface breaking something about boost::thread
> or if the different environment is revealing a flaw with my code.

As it turns out, I get the same results with a trivial program:

void doNothing() { return; }

void doWork() {
    boost::thread t1(doNothing);

This runs fine standalone -- though DRD in Valgrind 3.7 gives me tons of
errors when I run this with Boost 1.48 on my Mac -- but segfaults
intermittently when run from matlab.

Is this definitely a matlab problem? I'm not sure how it really could be,
but it also seems incredibly unlikely that there would be a race condition
or something in such a basic component of Boost.Thread.

Any thoughts?

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at