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

start: make stack size strategy configurable #18760

Closed
wants to merge 3 commits into from
Closed

start: make stack size strategy configurable #18760

wants to merge 3 commits into from

Conversation

Aransentin
Copy link
Contributor

With this PR, one can specify what Linux stack-resizing behaviour by setting the appropriate option in std_options. There are three possibilities:

  • none, which relies on the default Linux stack size of 8 MiB.
  • program_header, which will look through the ELF headers set the stack size using setrlimit. This is the current and default behaviour.
  • fixed, which sets the value to a configurable fixed size, compile-time asserted to be divisible by the page size as the syscall wants.

If you don't set any of these values the default of program_header is chosen, which is the current behaviour, so this PR should have no effect on existing code.

This makes makes it possible to remove unnecessary cruft if one e.g. lacks the CAP_SYS_RESOURCE capability (as that is required for increasing values with setrlimit), or when you don't mind the default 8MiB (Those extra setrlimits totally cramp our style when doing "Hey, look what I can do in X bytes and Y syscalls!" demos).

The ".fixed" option means one could also implement a "manual" version of #1639 by using runtime analysis tools. This entire thing should still be revisited when/if that is handled, but I perhaps this PR is an improvement to the status quo.

(this is a fix of a previous PR, #17830, which I think failed the CI due to allowing stack size shrinking.)

Copy link
Contributor

@rootbeer rootbeer left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me (an unofficial reviewer).

Would be great if there was some way to at least exercise the different strategies in Zig's tests.... You might be able to follow some of the examples in test/standalone/?

@Aransentin
Copy link
Contributor Author

Would be great if there was some way to at least exercise the different strategies in Zig's tests.... You might be able to follow some of the examples in test/standalone/?

I suppose I could – but failing to set the stack size is intentionally a silent failure, which means the tests won't actually report any errors in any case. I did verify (with strace) that the different strategies do what they are supposed to do, at least.

@Aransentin Aransentin closed this by deleting the head repository Aug 19, 2024
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.

2 participants