3

I'm working on a shiny server and I'm doing some quite complex operations. The problem I've found is that, after some minutes working on large data frames, the app crashed with this error: Error: C stack usage 7969194 is too close to the limit. Execution halted. I googled it and I've found that from the cmd in ubuntu with this command ulimit -s 16384 you can augment the stack size but I didn't find how to do it in the shiny server.

Please, does someone have some ideas?

Thank you

  • 1
    I have exactly the same problem: I do not seem to be able to tell the shiny server to run the system R with setting the ulimit differently. Does it work if you set the ulimit internally, with a system command or with ulimit::memory_limit(2000)? – Federico Giorgi Mar 02 '20 at 15:54
  • 2
    I bet this has more to do with a logic error in a function that's triggering some sort of infinite recursion. Changing the ulimit probably won't help much. But it's hard to tell without a proper minimal [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Have you tested and verified all your functions outside the shiny environment first? – MrFlick Mar 02 '20 at 16:25

1 Answers1

0

TLDR:

Add the following lines to the end of /etc/security/limits.conf:

* soft memlock unlimited
* hard memlock unlimited

* soft stack unlimited
* hard stack unlimited

Credited to this answer. Bascially this change will adjust the size of stack and memlock memories to unlimited.

More Background:

As OP points out, one can use ulimit to adjust available stack size before entering an R session.

The R package rlimit is supposed to work just like the command line utility ulimit, however, I cannot produce the same behavior after entering into an R session:

Cstack_info()["size"] # prints 7969177
rlimit_stack(16384, 16384) # expect 16777216
Cstack_info()["size"] # still prints 7969177

Eventually I found the above TLDR solution and Error: C stack usage 7969194 is too close to the limit. Execution halted. goes away.

Huang C.
  • 398
  • 6
  • 17