[Mono-dev] glibc detected *** mono: double free or corruption

Rolf Bjarne Kvinge rolflists at ya.com
Tue Oct 16 03:42:08 EDT 2007

>From: StApostol [mailto:stapostol at gmail.com] 
>Sent: lunes, 15 de octubre de 2007 15:25
>To: Rolf Bjarne Kvinge
>Cc: mono-devel-list at lists.ximian.com
>Subject: Re: [Mono-dev] glibc detected *** mono: double free or corruption
>I am receiving the same error message, but in my case I think it is linked
to pinvoking an array of strings (string[]). The error occurs during garbage
>collection/object disposal, at application shutdown.
>I do have a somewhat simple test-case, but unfortunately it is part of a
larger project. You can download the source code and (release) binaries from
>the following link: 
>Execute Examples.exe and select "Tutorial 10: GLSL Cube" from the listbox.
The error occurs during applicaton shutdown.
>The source code for the example can be found online at:
/Tutorial/T10_GLSL_Cube.cs?revision=501&view=markup (check the OnLoad and
>OnUnload functions).
>It seems likely that the problem is linked with the marshalling of structs.
In my case, this happens with the GL.ShaderSource() function inside the
>OnLoad method. Its pinvoke signature is as follows:
>[DllImport(GL.Library, EntryPoint = "glShaderSource", ExactSpelling =
true), SuppressUnmanagedCodeSecurity]
>internal extern static unsafe void ShaderSource(UInt32 shader, Int32 count,
System.String[] @string, Int32* length);
>The C signature is:
>void glShaderSource(GLuint shader, GLsizei count, const GLchar **string,
const GLint *length)
>Any ideas? I can provide more information as necessary, but I don't believe
I can rewrite a more minimal test-case. 

C-code typically expects the string array to end with a null element, I
can't see that you're doing that in your code.

Otherwise you might want to try to create the array manually using the
System.Runtime.Interop.Marshal class (use AllocHGlobal to create the array
memory, then StringTo* to create unmanaged versions of the string) to see if
that works.


>On 10/15/07, Rolf Bjarne Kvinge <rolflists at ya.com> wrote:
>>From: mono-devel-list-bounces at lists.ximian.com
>[mailto:mono-devel-list-bounces at lists.ximian.com ] On Behalf Of Abir
>>Sent: lunes, 15 de octubre de 2007 15:00
>>To: mono-devel-list at lists.ximian.com
>>Subject: [Mono-dev] glibc detected *** mono: double free or corruption 
>>Hi All,
>>Am receiving an native crash error like : *** glibc detected *** mono:
>double free or corruption (!prev): 0x08726100 ***. I am trying to call a
>PInvoke to a 'C' method which returns me a struct. I am using Fedora ( 2.6)
>and have >installed mono from the standard installer :
>Could you attach the C and C# code necessary to reproduce this?
>Otherwise it's impossible to tell where the problem is.

More information about the Mono-devel-list mailing list