[Mono-bugs] [Bug 78379][Nor] Changed - Tao.Sdl crashes with glibc detected free() only on Linux

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon May 15 07:01:39 EDT 2006

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by vargaz at gmail.com.


--- shadow/78379	2006-05-15 04:37:17.000000000 -0400
+++ shadow/78379.tmp.11664	2006-05-15 07:01:39.000000000 -0400
@@ -81,6 +81,35 @@
 really a bug?
 isnt there a way to work around this ? purely on the mono side.
 if not, Tao.Sdl may be dead.
 how can someone use it, if u cant query the error message?
 i dont know much about pinvoke... if u can give me a hint
+------- Additional Comments From vargaz at gmail.com  2006-05-15 07:01 -------
+SDL is perfectly fine, it is the C# wrapper method which needs to be
+changed. i.e, instead of 
+		public static extern string SDL_GetError();
+there should be an internal method:
+		public static extern IntPtr SDL_GetError_Internal();
+and the real SDL_GetError () method should look something like this:
+public static string SDL_GetError () {
+   return Marshal.PtrToStringAnsi (SDL_GetError_Internal ());
+notice that the return type of SDL_GetError_Internal () is now
+'IntPtr', so the runtime doesn't try to free the value returned by the
+C function.
+The above solution works only if the native SDL_GetError () function
+allways returns static memory, if it returns dynamic memory, that will
+be leaked.

More information about the mono-bugs mailing list