GtkSharp/GtkSharp

[macos/arm64] Invalid `int` mapping for `gssize`, e.g. inside `g_filename_from_utf8` signature

spouliot opened this issue · 1 comments

The 2nd argument of g_filename_from_utf8 [1] is a gssize [2] which should be 64 bits on 64 bits architectures. Due to ABI this does not seems to have caused problems before now (on x86_64) but this does not work correctly on arm64.

References

[1] https://developer-old.gnome.org/glib/stable/glib-Character-Set-Conversion.html#g-filename-from-utf8
[2] https://developer-old.gnome.org/glib/stable/glib-Basic-Types.html#gssize

Test

	[Test]
	public void StringToFilenamePtr ()
	{
		var p = Marshaller.StringToFilenamePtr ("benchmark-results");
		Assert.That (p, Is.Not.EqualTo (IntPtr.Zero), "not null");
		Marshaller.Free (p);
	}

Results

  Failed StringToFilenamePtr [103 ms]
  Error Message:
   GLib.GException : Invalid byte sequence in conversion input
  Stack Trace:
     at GLib.Marshaller.StringToFilenamePtr(String str) in /Users/poupou/git/external/GtkSharp/Source/Libs/GLibSharp/Marshaller.cs:line 134
   at Tests.Tests.StringToFilenamePtr() in /Users/poupou/git/external/GtkSharp/Tests/GLib/Marshaller.cs:line 19

Failed!  - Failed:     1, Passed:     1, Skipped:     0, Total:     2, Duration: 110 ms - /Users/poupou/git/external/GtkSharp/Tests/bin/Debug/net6.0/Tests.dll (net6.0)

The signature for g_filename_to_utf8 suffers from the same mistake and does not work, as is, on macos/arm64. There might be more of them (more than 300 delegates uses int parameters).