Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4757771

Browse filesBrowse files
addaleaxtargos
authored andcommitted
src: add consistency check to node_platform.cc
We use the `Isolate*` pointer as the sole identifier for a V8 Isolate. In some environments (e.g. multi-threaded), Isolates may be destroyed and new ones created; then, it may happen that the memory that was previously used for one `Isolate` can be re-used for another `Isolate` after the first one has been disposed of. This check is a little guard against accidentally re-using the same per-Isolate platform data structure in such cases, i.e. making sure (to the degree to which that is possible) that the old `Isolate*` has been properly unregistered before one at the same memory address is added. (It’s not 100 % foolproof because the `uv_loop_t*` pointer value could theoretically be the same as well.) PR-URL: #21156 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 79b3423 commit 4757771
Copy full SHA for 4757771

File tree

Expand file treeCollapse file tree

2 files changed

+3
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+3
-0
lines changed
Open diff view settings
Collapse file

‎src/node_platform.cc‎

Copy file name to clipboardExpand all lines: src/node_platform.cc
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ void NodePlatform::RegisterIsolate(IsolateData* isolate_data, uv_loop_t* loop) {
141141
Mutex::ScopedLock lock(per_isolate_mutex_);
142142
std::shared_ptr<PerIsolatePlatformData> existing = per_isolate_[isolate];
143143
if (existing) {
144+
CHECK_EQ(loop, existing->event_loop());
144145
existing->ref();
145146
} else {
146147
per_isolate_[isolate] =
Collapse file

‎src/node_platform.h‎

Copy file name to clipboardExpand all lines: src/node_platform.h
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ class PerIsolatePlatformData :
7272
bool FlushForegroundTasksInternal();
7373
void CancelPendingDelayedTasks();
7474

75+
const uv_loop_t* event_loop() const { return loop_; }
76+
7577
private:
7678
void DeleteFromScheduledTasks(DelayedTask* task);
7779

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.