Segfault when calling library function that works correctly standalone

So there’s this very basic example of finding the roots of unity using the MPSolve library. Calling from C

void test_mps(void);

int main(void)
  return 0;

gives the correct results and passes valgrind check. However, when called from Julia

ccall((:test_mps, "./libmps_test"), Cvoid, ())

it prints

Enter solver

and then fails with “Segmentation error”. What could be causing this behaviour? The library uses libpthread internally, perhaps it conflicts with jula runtime somehow?

Here are very little chance of conflict caused by pthread.

The more likely reason is for c bug to be triggered when called in a less clean context, or if encode is using gmp/mpfr, the allocator Julia supplies to it can’t run on unmanaged thread (even though it’s thread safe). I think the second issue was fixed recently.

The library in question uses GMP internally. Where the “second issue” has been fixed? The latest GMP release is from 2016, julia version is 1.2

The fix is in outside and couldn’t easily check…

Do you mean that it could be in v1.3.0-rc4 ?

EDIT: Yep, works after upgrading to 1.3.0-rc4. Thanks for the tip