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

enable v8_enable_local_off_stack_check compile time flag #2752

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

anonrig
Copy link
Member

@anonrig anonrig commented Sep 19, 2024

Referencing the original commit introducing the flag:

This CL introduces a compile-time flag v8_enable_local_off_stack_check
which enforces a run-time DCHECK, that all v8::Local objects are
indeed stack-allocated. The check is disabled by default. It will
fail for all heap data structures containing local handles.

Local handles (object of the v8::Local) should never be allocated on the heap, and we should use v8::LocalVector instead of heap allocation. This flag ensures that we follow v8 recommendation.

@anonrig anonrig requested review from a team as code owners September 19, 2024 20:47
.bazelrc Outdated
@@ -61,6 +61,9 @@ build --host_per_file_copt='external/zlib@-Wno-unknown-warning-option,-Wnodeprec
build --per_file_copt=external/com_google_tcmalloc@-DANNOTATE_MEMORY_IS_INITIALIZED=ABSL_ANNOTATE_MEMORY_IS_INITIALIZED
build --per_file_copt=external/com_google_protobuf@-Wno-deprecated-declarations,-Wno-deprecated-pragma
build --host_per_file_copt=external/com_google_protobuf@-Wno-deprecated-declarations,-Wno-deprecated-pragma
# Enables heap allocation debug checks for local handles.
# Ref: https://chromium-review.googlesource.com/c/v8/v8/+/4905902
build --per_file_copt='external/v8@-DV8_ENABLE_LOCAL_OFF_STACK_CHECK'
Copy link
Collaborator

@fhanau fhanau Sep 19, 2024

Choose a reason for hiding this comment

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

Actually I was wrong about this only being needed when building V8: Since the define present in include/v8-local-handle.h and include/v8-fast-api-calls.h we also need to apply it when building our own code. Let's change this to a regular copt.

@fhanau
Copy link
Collaborator

fhanau commented Sep 19, 2024

Nit: We reproduce V8 build flags in compile_flags.txt so that they are available to clangd when editing code – let's add the define there too.

@anonrig
Copy link
Member Author

anonrig commented Sep 20, 2024

I've submitted a patch to v8 to fix this error. https://chromium-review.googlesource.com/c/v8/v8/+/5876953

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.

3 participants