-
-
Notifications
You must be signed in to change notification settings - Fork 560
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
Memory limits bypass #887
Comments
MaxArraySize constraint in #923 should address this. |
Would you like to submit a PR to improve the protections? |
I have zero experience with the Jint code. Do you have a suggestion what kind of solution would be appropriate? I'm guessing the reason this isn't working properly is that a really fundamental solution (e.g. check memory usage at every instantiation of a JS value/object) would cause an unacceptable performance hit. |
Start by creating a failing test case when you have engine configured to have array and memory usage constraint |
What about checking for the constraint inside native functions if at they represent a risk? We could set a flag and the callers could also check? For instance But maybe a better idea would be to have an internal field that track an estimation of allocated memory in native functions, a hint, and above a threshold do a constraint check. So for every |
I had a vision where native functions would get a CancellationToken as part of call signature which would be cheap to check. Constrainst could hook onto that that like as combined source and constraints could even run a background task (think thread), a watchdog, that could signal token when things start to look bad. Just an idea. |
in the Engine then, doesn't need to be in the signature |
But it's orthogonal to my idea. What about it? |
Yes the signature was more about aligning with standards, but could be a field too. |
Also wondering if we should track the size of each environment record, such that when one is remove we can decrease the allocations. Imagine a long running script that just updates the same entry with a 1MB buffer, it allocates a lot overtime, but only takes 1MB in total. So there would be two checks, that what we allocate doesn't go over the limit, and only account for retained memory when adding the allocated buffers. |
I think it's fine to not check the actual memory usage of each array or string allocations though. These could use an option with a max length instead, even very big. Then throw a specific exception. And concatenations would check upon this limit instead of the thread memory.
The
fill
function however might need to check the memory limits. There might be other functions too that loop over the same value and need a check. Looping over a function evaluation is safe though since thread memory is ensured.The text was updated successfully, but these errors were encountered: