Skip to content

Ensure that converted objects are pinned to avoid invalid accesses due to memory movement#117

Open
Braedon-Wooding-Displayr wants to merge 1 commit intoJavascriptNet:masterfrom
Braedon-Wooding-Displayr:pin-converted-objects
Open

Ensure that converted objects are pinned to avoid invalid accesses due to memory movement#117
Braedon-Wooding-Displayr wants to merge 1 commit intoJavascriptNet:masterfrom
Braedon-Wooding-Displayr:pin-converted-objects

Conversation

@Braedon-Wooding-Displayr

We can't trust gc_root since it doesn't pin the memory so we need to use pin_ptr or gc handle. I've opted for gc handle here for no specific reason.


ConvertedObjects::~ConvertedObjects()
{
// Delete gcroot pointers using C++ vector - no V8 operations needed.

Choose a reason for hiding this comment

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

gc roots don't pin the memory so we can't hold them as ptrs.

This is only really safe right now is because memory only moves for long lived memory (short lived memory never moves) and all these converted objects fall under short lived memory.

Copy link
Contributor

@oliverbock oliverbock left a comment

Choose a reason for hiding this comment

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

Looks like a good change, though it's been a long time since I've used any of this stuff so I might be wrong. Perhaps check with Brandon too.

Copy link
Collaborator

@bwinsley bwinsley left a comment

Choose a reason for hiding this comment

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

LGTM

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