◐ Shell
clean mode source ↗

src: warn about FastOneByteString invalidation · nodejs/node@42ef814

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);