Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maximize system stacksize limit #1233

Merged
merged 2 commits into from
Jul 13, 2023
Merged

Maximize system stacksize limit #1233

merged 2 commits into from
Jul 13, 2023

Conversation

J-Lentz
Copy link
Contributor

@J-Lentz J-Lentz commented May 23, 2023

Description
A small C function, invoked by fms_init, has been added to raise the system stack size limit to its maximum permissible value. This change prevents segmentation faults due to the default stack size limit, which can otherwise occur if a user forgets to run ulimit -s unlimited.

How Has This Been Tested?
Compiles with Intel and GNU on the AMD box.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included
  • make distcheck passes

Use `getrlimit` and `setrlimit` from the POSIX `sys/resource.h` API to set the
stacksize limit to its maximum permissible value. This is done via a C function
which is invoked by `fms_init`.
rem1776
rem1776 previously approved these changes May 23, 2023
Comment on lines +28 to +32
struct rlimit stacksize;

getrlimit(RLIMIT_STACK, &stacksize);
stacksize.rlim_cur = stacksize.rlim_max;
setrlimit(RLIMIT_STACK, &stacksize);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we typically test on SLES, ubuntu, and Centos, but please make an effort to ensure the struct and function exist and works the same way on Mac OS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested it on Mac OS, but sys/resource.h is a POSIX API (see: resource.h specification) which includes getrlimit(), setrlimit(), struct rlimit, and the RLIMIT_STACK constant. I believe Mac OS is POSIX-compliant, so compatibility shouldn't be an issue.

@rem1776 rem1776 merged commit 8eb24f8 into NOAA-GFDL:main Jul 13, 2023
ganganoaa pushed a commit to ganganoaa/FMS that referenced this pull request Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants