Ensure that converted objects are pinned to avoid invalid accesses due to memory movement#117
Conversation
…e to memory movement
|
|
||
| ConvertedObjects::~ConvertedObjects() | ||
| { | ||
| // Delete gcroot pointers using C++ vector - no V8 operations needed. |
There was a problem hiding this comment.
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.
oliverbock
left a comment
There was a problem hiding this comment.
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.
|
Disclaimer: I don't work much with C++/CLR, This change looks more unsafe to me and in fact the previous code seems completely fine. From what I understand (and you can see that by inspecting the header file), a This PR now basically does what |
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.