Skip to content

Added mremap tracing and fixed a bug in MemoryLimitListener #43

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

Merged
merged 2 commits into from
Feb 10, 2024

Conversation

mikimasn
Copy link
Contributor

@mikimasn mikimasn commented Feb 6, 2024

Added mremap syscall tracing in the MemoryLimitListener to catch when the memory limit is exceeded and report a "memory limit exceeded" error instead of returning another possibly unrelated error (segfault, non-zero error code).

I also fixed a bug that caused the error ''memory limit exceeded'' to be displayed when there was no memory limit.

The error was caused by allocating more than MEMORY_LIMIT_MARGIN/2 bytes of memory in a single mmap call, which resulted in post-allocation memory usage being compared to the memory limit(which was zero).

Copy link
Member

@Wolf480pl Wolf480pl left a comment

Choose a reason for hiding this comment

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

Thanks for finding the issue and sending the pull request.

The changes look mostly correct from functionality point of view, most of my remarks are about the coding style. (Which is still important, because it makes it easier to see what's going on, and sio2jail is quite complex.)

The only behavior-affecting concern I have is about the second commit, and this is because there aren't many people with time for maintaining sio2jail so I want to be extra cautious that we don't break anything.

Once you fix that and the stylistic issues, and after we've tested the changes (either I or someone else from the team will try to do it later this week), we'll be able to merge it.

Copy link
Member

@Wolf480pl Wolf480pl left a comment

Choose a reason for hiding this comment

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

The code looks good, thanks for making the fixes.

Also, I did some testing, looks like it passes the existing testsuit and I also checked by hand that indeed the two issues with memory limit existed before and are fixed by these changes.

Looks good to go, I'll merge this tomorrow.

@Wolf480pl Wolf480pl merged commit 3867617 into sio2project:master Feb 10, 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