Skip to content

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

Open
@HenrikAkseliValve

Description

@HenrikAkseliValve
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);
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions