Skip to content

Conversation

@chadrockey
Copy link

Attempt for #257 @joseph-henry

@chadrockey
Copy link
Author

I added another commit since it's so near by. Turns out the C# garbage collector can move the byte[] memory and that the unsafe memory call must always be accompanied by pinning the memory so the garbage collector knows not to move that block.

See the comment on this documentation: https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.marshal.unsafeaddrofpinnedarrayelement?view=net-8.0

The likely symptoms are that the memory returned is suddenly all zeroes if it's been cleared or that suddenly the memory turns from expected values to zeroes for the rest of the data. I did not see a situation where it was moved to random or non-zeroed memory.

I believe it's ok to call this multiple times and here rather than in the user code, but I'm not quite sure.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

2 participants