-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Marshal.PtrToStructure fails to split strings in .NET Core 5 #54662
Labels
Milestone
Comments
dotnet-issue-labeler
bot
added
area-Interop-coreclr
untriaged
New issue has not been triaged by the area owner
labels
Jun 24, 2021
On .NET Core 3.1 it outputs "01" and "2" too. |
Thanks @huoyaoyuan I Added a .NET Fiddle to the issue, it runs in .net 5 with all the code that a friend reported to me that failed, built another solution for him, but there it fails. |
jkoritzinsky
added a commit
to jkoritzinsky/runtime
that referenced
this issue
Jun 24, 2021
…ches for a null terminator. Fixes dotnet#54662
AaronRobinsonMSFT
removed
the
untriaged
New issue has not been triaged by the area owner
label
Jun 24, 2021
ghost
added
the
in-pr
There is an active PR which will close this issue when it is merged
label
Jun 24, 2021
jkoritzinsky
added a commit
that referenced
this issue
Jun 28, 2021
…alTStr fields (#54695) * Use string constructor that takes length instead of the one that searches for a null terminator. Fixes #54662 * Marshal back buffer size or string to first null terminator, whichever is shorter * Add tests. * Add unicode test. * Use the same implementation style for the wstr case case as the cstr case * Fix accidental deletion from test.
ghost
removed
the
in-pr
There is an active PR which will close this issue when it is merged
label
Jun 28, 2021
ghost
locked as resolved and limited conversation to collaborators
Jul 28, 2021
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When marshaling a BSTR to a Struct it fails to split the strings as it did in .NET Framework 4.7.2
Edit
Added a test on .NET Fiddle:
Test Marshal.PtrToStructure NET 5
Description
On the following example a string of "012", should be split into "01" a "2" but the strings point to the correct position but doesn't contain the correct ending mark for the first one, so the result would be "012" and "2". Yes it's obvious that a masrsahlling of the bytes directly to the struct would produce this behavior, but I would file it as a bug, not a feature. My string obviously is a 64 character long with 13 fields, this is just a small example of the problem.
Configuration
Visual Studio 2019 16.10.1
.NET Core 5
Windows 10.0.19042.1052
64bit
Not specific to configuration
Regression?
It works fine in .net 4.7.2
The text was updated successfully, but these errors were encountered: