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

Fix handling of memory limit #385

Merged
merged 2 commits into from
May 6, 2024
Merged

Fix handling of memory limit #385

merged 2 commits into from
May 6, 2024

Conversation

saghul
Copy link
Contributor

@saghul saghul commented Apr 16, 2024

Default to 0, which is "disabled", just like the stack limit.

quickjs.c Outdated Show resolved Hide resolved
qjs.c Outdated Show resolved Hide resolved
qjs.c Outdated
Comment on lines 417 to 448
// TODO(chqrlie): accept kmg suffixes
stack_size = (size_t)strtod(opt_arg, NULL);
stack_size = (int)atoi(opt_arg);
break;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same remark

qjs.c Outdated Show resolved Hide resolved
quickjs.c Outdated Show resolved Hide resolved
quickjs.c Outdated Show resolved Hide resolved
@saghul
Copy link
Contributor Author

saghul commented Apr 16, 2024

I'll give it another shot.

@saghul saghul marked this pull request as draft April 19, 2024 09:30
Default to 0, which is "disabled", just like the stack limit.
@saghul saghul force-pushed the fix-memory-limit branch 2 times, most recently from 55ecf9d to 4b83dd2 Compare April 23, 2024 12:41
@saghul saghul marked this pull request as ready for review April 23, 2024 12:41
@saghul
Copy link
Contributor Author

saghul commented Apr 23, 2024

@chqrlie PTAL and let me know what you think!

@chqrlie
Copy link
Collaborator

chqrlie commented May 1, 2024

@saghul : as you changed the default unit, you should update the v8.js test file:

-                   "--stack-size", `${flags["--stack-size"]*1024}`,
+                   "--stack-size", `${flags["--stack-size"]}`,

This will fix the ci / linux (Release) test failure.

@saghul
Copy link
Contributor Author

saghul commented May 1, 2024

Good one! I got a bit busy and hadn't dug deep enough, thanks for the pointer!

@saghul
Copy link
Contributor Author

saghul commented May 5, 2024

@chqrlie Updated, PTAL!

@chqrlie
Copy link
Collaborator

chqrlie commented May 5, 2024

@chqrlie Updated, PTAL!

Hi @saghul !
You only addressed the v8 issue. Any reason not to simplify parse_limit?

@saghul
Copy link
Contributor Author

saghul commented May 5, 2024

@chqrlie Updated, PTAL!

Hi @saghul !

You only addressed the v8 issue. Any reason not to simplify parse_limit?

I'm not seeing any comments on that function on GH. I wonder if they got lost with the force push.

Can you please repeat? :-)

qjs.c Show resolved Hide resolved
qjs.c Outdated
Comment on lines 496 to 499
if (memory_limit >= 0)
JS_SetMemoryLimit(rt, (size_t)memory_limit * 1024 /* QuickJS needs bytes. */);
if (stack_size >= 0)
JS_SetMaxStackSize(rt, (size_t)stack_size * 1024 /* QuickJS needs bytes. */);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do not multiply by 1024 if you use my proposed version for parse_imit.

@chqrlie
Copy link
Collaborator

chqrlie commented May 5, 2024

@chqrlie Updated, PTAL!

Hi @saghul !
You only addressed the v8 issue. Any reason not to simplify parse_limit?

I'm not seeing any comments on that function on GH. I wonder if they got lost with the force push.

Can you please repeat? :-)

Sorry, I had not published my review...

Switch the default in the CLI to kilobytes too.
@saghul
Copy link
Contributor Author

saghul commented May 6, 2024

@chqrlie Thanks a lot for the remark on strtod I wasn't aware of it! Updated, PTAL!

@saghul saghul merged commit 6cb1301 into master May 6, 2024
47 checks passed
@saghul saghul deleted the fix-memory-limit branch May 6, 2024 09:22
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