[Python.NET] building on linux, mono 2.8.1

Tribble, Brett btribble at ea.com
Thu Dec 9 04:47:12 CET 2010


Your long self-conversation is the most interesting thing to happen to this list in a long time...

From: pythondotnet-bounces+btribble=ea.com at python.org [mailto:pythondotnet-bounces+btribble=ea.com at python.org] On Behalf Of Laszlo Sebo
Sent: Wednesday, December 08, 2010 5:45 PM
To: pythondotnet at python.org
Subject: Re: [Python.NET] building on linux, mono 2.8.1

At the risk of having a long conversation here with myself... :)

It appears that the crash happens in intobject.c of python, at the PyObject *PyInt_FromLong(long ival) function, when it tries to increment the reference counter: Py_INCREF(v);
When python.net calls this function first, it calls it with the value of 0, which falls into a special handled range of integers that are dealt with in a small_ints[] array. However, that array never go initialized, so the reference counter crashes.

The array would normally be initialized by calling _PyInt_Init(void). Sooo... just to test my theory, i exposed that function and called it explicitly from
Python.Runtime.Initialize() and low and behold, import clr now works just fine!

So i'll now go on a hunt, and make sure everything is initialized properly, i'm guessing some main init function isn't being called somewhere when using python.net from an embedded python.


cheers,
laszlo


On 08/12/2010 1:35 PM, Laszlo Sebo wrote:
Made a little bit of progress, but am now back to square one.. :)

Basically, seems that the python embedded in nuke uses UCS4 instead of UCS2 which is the default when building python. So the python so's i had were using UCS2 while Nuke's internal python was using UCS4. I rebuilt python using the --enable-unicode=ucs4 flag, then rebuilt python.net.

I hit another wall fairly soon, the mono config (dll remap) file wasn't being initialized, so i would be getting missing msvcrt dll errors on import clr.
To fix that, i had to uncomment this line in pynetinit.c:
//mono_config_parse(NULL);

However, now i am back to the previous error i had:

Stacktrace:

  at (wrapper managed-to-native) Python.Runtime.Runtime.PyInt_FromLong (intptr) <0x00060>
  at (wrapper managed-to-native) Python.Runtime.Runtime.PyInt_FromLong (intptr) <0xffffffff>
  at Python.Runtime.Runtime.PyInt_FromInt32 (int) <0x0006b>
  at Python.Runtime.Runtime.Initialize () <0x00433>
  at Python.Runtime.PythonEngine.Initialize () <0x00073>
  at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) <0xffffffff>


oh well... anybody managed to get python.net working with UCS4 python?


cheers,
laszlo

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20101208/b3de4044/attachment-0001.html>


More information about the PythonDotNet mailing list