-----BEGIN PGP SIGNED MESSAGE-----
Suraj K. wrote:
I was using the pthread library, with default attribute values
(thread stack size = 2 MiB) for pthread_create(), to launch the Ruby
interpreter. Naturally, the interpreter eventually ran out of stack
space and produced the SystemStackError.
I am thrilled to report that the problem has been solved!
First, I investigated what the pthreads library was assigning as the
default value for the stack size (see output below).
Next, I tried increasing the stack size via
pthread_attr_setstacksize() to 256 MiB, but this did not work.
Eventually, I happened upon “rlimit”, the system resource limits,
while searching USENET archives and decided to see what those values
were on my system.
common_debug(“pthread_attr_getstacksize() => %d bytes”, stackSize);
common_debug(“PTHREAD_STACK_MIN => %d bytes”, PTHREAD_STACK_MIN);
common_debug(“checking stack rlimit”);
struct rlimit lim;
common_debug(“current limit = %d bytes”, lim.rlim_cur);
common_debug(“maximum limit = %d bytes”, lim.rlim_max);
The above snippet produced the output below:
(src/relay.cin:70) Ruby-VPI: pthread_attr_getstacksize() => 8388608
(src/relay.cin:71) Ruby-VPI: PTHREAD_STACK_MIN => 16384 bytes
(src/relay.cin:74) Ruby-VPI: checking stack rlimit
(src/relay.cin:77) Ruby-VPI: current limit = 8388608 bytes
(src/relay.cin:78) Ruby-VPI: maximum limit = -1 bytes
Interesting! (Notice that the values produced by lim.rlim_cur and
pthread_attr_getstacksize() are the same.)
So, the pthreads library was indeed trying to assign as much stack
space as it could to the thread (which, in my code, runs the Ruby
Armed with this knowledge, I simply increased the resource limit for
the stack size to unlimited at my command-prompt (by running "ulimit
- -s unlimited") and re-executed my program. And this time, the
SystemStackError did not occur!
Thank you everyone for helping me figure out this problem. Now I can
sleep peacefully at night.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
-----END PGP SIGNATURE-----