Open 3F opened 1 month ago
https://github.com/3F/Conari/blob/ba1a82e1a7c9250e5806b5d72444be5c3b57850c/Conari/Types/NativeString.cs#L91-L96
Yep, WriteTo() actually writes beyond allocated region if WCharPtr or TCharPtr (when Unicode=true) this ultimately leads to such consequences:
WriteTo()
either ok, or:
The active test run was aborted. Reason: Test host process crashed
or:
Error Message: Assert.Equal() Failure: Strings differ Expected: "Рад знакомству 🤝 どうぞよろしく" Actual: null
https://ci.appveyor.com/project/3Fs/dllexport-ix27o/builds/50882366#L297
and so on.
Test can be found here: https://github.com/3F/DllExport/blob/9db4bf0ba6793523d12eb0a1680c0cd962283f19/src/DllExport/UnitedTest/NetfxAssetBasicTest.cs#L36
But I also forgot about the new disposing (that's another, actually even more interesting story*)
l.callme<TCharPtr>(ns + " and You 👋", nstruct);
*because this part must be fully reviewed since this creates non-obvious allocation which will lead to memory leaks
Note, you can avoid the error in Conari 1.5 easily with modern C# string interpolation, for example:
using NativeString<TCharPtr> nw = new($"{ns} and You 👋"); l.callme<TCharPtr>(nw, nstruct);
https://github.com/3F/Conari/blob/ba1a82e1a7c9250e5806b5d72444be5c3b57850c/Conari/Types/NativeString.cs#L91-L96
Yep,
WriteTo()
actually writes beyond allocated region if WCharPtr or TCharPtr (when Unicode=true) this ultimately leads to such consequences:either ok, or:
or:
https://ci.appveyor.com/project/3Fs/dllexport-ix27o/builds/50882366#L297
and so on.
Test can be found here: https://github.com/3F/DllExport/blob/9db4bf0ba6793523d12eb0a1680c0cd962283f19/src/DllExport/UnitedTest/NetfxAssetBasicTest.cs#L36
But I also forgot about the new disposing (that's another, actually even more interesting story*)
*because this part must be fully reviewed since this creates non-obvious allocation which will lead to memory leaks