Skip to content
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

TestStdStringInField and TestArrayParams fail in debugging configuration on windows because std:string size is wrong. #1889

Open
HenrikAkseliValve opened this issue Jan 5, 2025 · 1 comment

Comments

@HenrikAkseliValve
Copy link
Contributor

Brief Description

Two tests didn't seem to succeed even after I reverted the code I was working on. The function call did go through, but some data coming from C# was uninitialized in C++. C# context everything looked fine.

It seems there is a size difference between C# std.BasicString (32 bytes) and C++ std::basic_string (40 bytes). These tests did not fail on the pull request #1887, hence I would conclude that Windows has some extra payload when compiling on debug.

How is Std.cs generated? With headers attached to Std module?
Is this just that CppSharp does not define _RELEASE or _DEBUG for clang, so the header is different from the binary?

OS: Windows

std::basic_string size on C++

image

std.BasicString on Std.cs on VTables.CSharp:
    namespace BasicString
    {
        [StructLayout(LayoutKind.Sequential, Size = 32, Pack = 8)]
        public unsafe partial struct __Internalc__N_std_S_basic_string__C___N_std_S_char_traits__C___N_std_S_allocator__C
        {
            internal global::Std.CompressedPair.__Internalc__N_std_S__Compressed_pair____N_std_S_allocator__C___N_std_S__String_val____N_std_S__Simple_types__C_Vb1 _Mypair;

            [SuppressUnmanagedCodeSecurity, DllImport("Std-symbols", EntryPoint = "??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ", CallingConvention = __CallingConvention.Cdecl)]
            internal static extern __IntPtr ctorc__N_std_S_basic_string__C___N_std_S_char_traits__C___N_std_S_allocator__C(__IntPtr __instance);

            [SuppressUnmanagedCodeSecurity, DllImport("Std-symbols", EntryPoint = "??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ", CallingConvention = __CallingConvention.Cdecl)]
            internal static extern void dtorc__N_std_S_basic_string__C___N_std_S_char_traits__C___N_std_S_allocator__C(__IntPtr __instance);
        }
    }
@HenrikAkseliValve
Copy link
Contributor Author

HenrikAkseliValve commented Jan 5, 2025

Doh, there was an old discussion on this #1365

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

No branches or pull requests

1 participant