Use isolate's cg-oom-killed to detect "memory limit exceeded" conditions - #1471
Merged
Conversation
gollux
approved these changes
Jul 23, 2025
gollux
left a comment
Contributor
There was a problem hiding this comment.
I agree, but please wait with merging until the end of this IOI.
pxsit
approved these changes
Jul 28, 2025
PHP has a memory_limit setting that limits the amount of memory the interpreter even tries to allocate; this limit is 128M by default. Exceeding this causes PHP to exit with code 255 (and print a message on stdout). This commit changes the limit to infinity, and lets isolate's memory limit handle it instead. This gives the correct feedback to contestants.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #912.
I deleted the extra text from killed-by-signal's help text because it's not relevant there anymore (I hope). I didn't re-add it to the new error's help text because in my experience, it's not true: in all cases I have tried, the oom killer has been precise enough that the reported memory use is exactly the task's memory limit (up to the rounding precision, at least). The behaviour that was described in that deleted paragraph might have been possible with non-cgroups isolate? I'm not sure.
Also, PHP has a
memory_limitsetting that limits the amount of memory the interpreter even tries to allocate; this limit is 128M by default. Exceeding this causes PHP to exit with code 255 (and print a message on stdout). This broke the new tests (and in fact, this could have been caught earlier: all the other oom tests were killed by signal, whereas php was nonzero exit code, but this fact was not checked by the test). Actually, this was a bigger problem, in that PHP enforced a 128MB memory limit, ignoring whatever the task's memory limit was. This would be possible to fix in php.ini on worker machines, but the contest administrators would have to be aware of it. I fixed it by changing the limit to -1 (meaning "infinite") using a command-line argument.