Skip to content

deps: fix --no-string_slices flag being read-only#63652

Closed
professional-slacker wants to merge 1 commit into
nodejs:mainfrom
professional-slacker:fix/string-slices-flag
Closed

deps: fix --no-string_slices flag being read-only#63652
professional-slacker wants to merge 1 commit into
nodejs:mainfrom
professional-slacker:fix/string-slices-flag

Conversation

@professional-slacker
Copy link
Copy Markdown

Summary

Change DEFINE_BOOL_READONLY to DEFINE_BOOL for the string_slices V8 flag so that --no-string_slices can be set at runtime.

The flag was defined as read-only, making it impossible to disable string slices even though the code already contains fallback paths for when string_slices is false.

Motivation

Long-running Node.js applications can experience memory issues caused by SlicedString retaining references to large parent strings. With this fix, users can pass --no-string_slices to force V8 to use copied substrings instead, avoiding the retention problem.

Changes

  • deps/v8/src/flags/flag-definitions.h:1088 β€” DEFINE_BOOL_READONLY β†’ DEFINE_BOOL

Existing fallback paths (already in codebase)

  • deps/v8/src/heap/factory.cc:1143 β€” if (!v8_flags.string_slices || ...) β†’ NewCopiedSubstring
  • deps/v8/src/builtins/builtins-string-gen.cc:2096 β€” if (v8_flags.string_slices) β†’ skip SlicedString
  • deps/v8/src/codegen/code-stub-assembler.cc:9328 β€” if (!v8_flags.string_slices || ...) β†’ expand SlicedString

Impact

  • Default value remains true β€” no behavior change unless --no-string_slices is explicitly passed
  • Allows runtime mitigation of SlicedString-related memory issues

Refs: https://github.com/nicolo-ribaudo/v8/commit/1e2a395

Change DEFINE_BOOL_READONLY to DEFINE_BOOL so that the
--no-string_slices V8 flag can be set at runtime. The flag was
defined as read-only, making it impossible to disable string
slices even though the code already contains fallback paths
for when string_slices is false (factory.cc, builtins-string-gen.cc,
code-stub-assembler.cc).

The default value remains true, so there is no change in behavior
for users who do not explicitly pass --no-string_slices.

Refs: https://github.com/nicolo-ribaudo/v8/commit/1e2a395
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/security-wg
  • @nodejs/v8-update

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. v8 engine Issues and PRs related to the V8 dependency. labels May 29, 2026
@professional-slacker
Copy link
Copy Markdown
Author

Closing β€” this should target v8/v8, not nodejs/node. Will reopen against the correct upstream.

@professional-slacker professional-slacker deleted the fix/string-slices-flag branch May 29, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. v8 engine Issues and PRs related to the V8 dependency.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants