#818 CSharp bindings and test-suite fail with memory errors

csharp (36)

I have been having a problem for a while now with the SWIG generated bindings for Xapian, which fail by displaying a "free(): invalid pointer" error message, and then hanging indefinitely.

Olly Betts pointed me at the "make check-csharp-test-suite" target for SWIG, which generates lots of errors for me (whether or not the errors are the same is unclear to me, but they certainly don't look good).

A log of the output generated by running "make check-csharp-test-suite" is attached. This output ends with the "constover" test, at which point the process hung indefinitely until I pressed CTRL-C.

I'm running Ubuntu Feisty, with:

$ mono --version
Mono JIT compiler version, (C) 2002-2006 Novell, Inc and Contributors. www.mono-project.com
TLS: __thread
GC: Included Boehm (with typed GC)
SIGSEGV: normal
Architecture: x86
Disabled: none

$ mcs --version
Mono C# compiler version

The "make check-csharp-test-suite" target passes with no errors for Olly, on a different machine with Mono JIT compiler version

For reference, details of the bug with Xapian are at http://www.xapian.org/cgi-bin/bugzilla/show_bug.cgi?id=132


  • Richard Boulton

    Richard Boulton - 2007-04-18

    Log of errors when running "make check-csharp-test-suite"

  • Richard Boulton

    Richard Boulton - 2007-04-18

    Logged In: YES
    Originator: YES

    We've found that moving to compile with gmcs instead of mcs fixes the Xapian bug, and is apparently needed to target the "mono 2.0" runtime (ie, mono versions from 1.2 onwards), so that is probably the fix for this issue. I haven't been able to fiddle the swig build system to make this change, but compiling a couple of the tests manually using gmcs instead of mcs seems to make them work.

  • William Fulton

    William Fulton - 2007-04-18

    Logged In: YES
    Originator: NO

    I can replicate the failures on Ubuntu Dapper Drake with the exact same mono and mcs versions. All I can say is I hope this isn't the default mono setup going into Feisty as there is something completely broken.

    The classic SWIG C# C++ example is in Examples/csharp/class. This one seg faults. I've narrowed the problem down to this most basic of runtime tests (replace the contents of runme.cs with the following):

    using System;

    public class runme
    static void Main()
    Shape shape = new Square(10);
    shape.x = -10;
    shape.y = 5;

    I think this needs to be investigated a bit further. But cutting out all the unnecessary initialisation code then submitting it all as a bug to mono is probably the next step.

  • William Fulton

    William Fulton - 2007-04-18

    Logged In: YES
    Originator: NO

    Output is:
    $ mono runme.exe

    Unhandled Exception: System.ArgumentNullException: Argument cannot be null.
    at (wrapper managed-to-native) examplePINVOKE:Shape_y_set (System.Runtime.InteropServices.HandleRef,double)
    at Shape.set_y (Double value) [0x00000]
    at runme.Main () [0x00000]

    Also occurs when removing all the string handling support code (which makes some callbacks from unmanaged to managed at initialisation). Do this by running swig -DSWIG_CSHARP_NO_EXCEPTION_HELPER.

  • William Fulton

    William Fulton - 2007-04-25
    • status: open --> closed

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks