[Xapian-devel] C# bindings and string typed return values

Greg freediving at gmail.com
Mon Apr 4 11:34:39 BST 2011

On Thu, Mar 31, 2011 at 11:30 AM, Olly Betts <olly at survex.com> wrote:
> On Wed, Mar 30, 2011 at 01:06:39PM +0200, Gregory wrote:
>> Generally the bindings work perfectly, except when called from an IIS
>> application and only when the function being called returns a string
>> eg. GetTerm() or GetValue(). Which results in the application pool
>> crashing.
>> Digging into the errors seems to yield the following "Attempted to
>> read or write protected memory. This is often an indication that other
>> memory is corrupt."
>> I've done a little research on the topic and found the following
>> http://stackoverflow.com/questions/370079/pinvoke-for-c-function-that-returns-char.
>> Which suggests that the pinvoke implementation for string/char
>> returning functions isn't implemented in a way that supports CLR calls
>> (at least not in IIS).
>> Is there something I could do to fix that on my end or is it something
>> that needs to be changed in the bindings.
> I'm not really an expert, but it sounds to me like it would be hard to
> work around, and should be fixed in the bindings.
> If you're able, the best approach would probably be for you to either
> modify the generated code for one of these methods so that it works in
> your environment, or produce a cut-down testcase which fails.  Then we
> can usefully raise it with the SWIG developers.
> Cheers,
>    Olly
Sorry I'm resurrecting this topic but I've been doing some debugging /
research on the string topic and it seem the problem is caused by a
change in .NET 4.0 CLR which apparently was fixed in SWIG 2.x see
for more information.

Are there any plans to migrate Xapian to use the latest version of SWIG?


More information about the Xapian-devel mailing list