Increase stack size of ffi lib

Hi,

I have a C++ lib I don't own that runs into a stack overflow because of a low stack default value.
Pretty sure it's running a recursive code.

I am on linux.
Running the command inside stacker::grow(stack_size, || {}) only works for the current rust thread apparently, not the lib.

Is there a way to tell the lib to increase its stack size ? Maybe via a build.rs variable?

Thanks

stacker::grow() creates extra stack space for the closure passed, while still running it on the same thread, so if you want to take that approach then the call to the C++ library needs to be in the closure.

Since you mention threads, you may be running the C++ code in its own thread, in which case another way to set the stack size is to create the thread using std::thread::Builder and call stack_size().

I don't think libraries themselves store stack size information. If the C++ library is creating its own threads or otherwise adjusting stack size internally, then it would only be changeable if it provides support for that (maybe an environment variable or argument to a call into the library). The documentation of the library would be the place to look for that.

2 Likes

Actually, the FFI call occurs in the stacker::grow(stack_size, || {})?
I even increased the stack like crazy and still the same issue.

Maybe something else is going on..

Thanks anyway!