Skip to content

Commit 42ef814

Browse files
jasnellRafaelGSS
authored andcommitted
src: warn about FastOneByteString invalidation
Minor warning about the use of FastOneByteString. PR-URL: #59275 Refs: cloudflare/workerd#4625 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 38aedfb commit 42ef814

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/node_buffer.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,14 @@ uint32_t FastWriteString(Local<Value> receiver,
15261526
uint32_t max_length,
15271527
// NOLINTNEXTLINE(runtime/references)
15281528
FastApiCallbackOptions& options) {
1529+
// Just a heads up... this is a v8 fast api function. The use of
1530+
// FastOneByteString has some caveats. Specifically, a GC occurring
1531+
// between the time the FastOneByteString is created and the time
1532+
// we use it below can cause the FastOneByteString to become invalid
1533+
// and produce garbage data. This is not a problem here because we
1534+
// are not performing any allocations or other operations that would
1535+
// trigger a GC before the FastOneByteString is used. Take care when
1536+
// modifying this code to ensure that no operations would trigger a GC.
15291537
HandleScope handle_scope(options.isolate);
15301538
SPREAD_BUFFER_ARG(dst_obj, dst);
15311539
CHECK(offset <= dst_length);

0 commit comments

Comments
 (0)