[Python.NET] Added 64-bit support, delegates/events broken?
John Burnett
JBurnett at blizzard.com
Mon Nov 19 21:01:37 CET 2007
Re-sending to get it posted to the maillist (really don't know how these
work, or how the threading is determined under
http://mail.python.org/pipermail/pythondotnet/2007-November/thread.html
).
----
Ok, I've submitted the patches. Note that I'm purely Windows here using
the Microsoft .NET framework, so I'm not sure what the fallout is on
mono or other platforms. The meat of the changes boils down to two
lines in the clrmodule file, but I gotta say it was fun getting back to
the IL:).
That said, here's the details for the two crashes I'm seeing:
My 32-bit machine is running XP Pro, and my 64-bit machine is running
Vista64 Business. Both machines have VS2005 and VS2008beta2 installed,
so I have .NET frameworks 2.0, 3.0, and 3.5.
In runtests.py, the two offending scripts are 'test_event' and
'test_delegate' (lines 36 and 38). I have to comment out one to see the
other run, since they both cause hard crashes in python.exe with an
unhandled exception.
In all cases below, I'm running the precompiled python 2.5.1 downloaded
from python.org.
For the 32-bit runs, I'm using a release build of clr.pyd that I
compiled under VS2005 from a download of pythonnet-2.0-alpha2.zip from
SourceForge. For the 64-bit runs, I'm running a release build of
clr.pyd compiled under VS2005 based on the patches I just submitted.
The "only" difference between the 32-bit and 64-bit exception traces is
that the 64-bit version has an extra entry in the call stack (a call to
Python.Runtime.CodeGenerator.DefineType(String name, Type basetype)).
Any ideas, or need any additional details that I can provide? :)
Cheers,
John
**** 32-bit, test_event ****
Unhandled Exception: System.TypeInitializationException: The type
initializer for 'Python.Runtime.CodeGenerator' threw an exception. --->
System.InvalidCastException: Unable to cast object of type
'System.Reflection.Module' to type
'System.Reflection.Emit.ModuleBuilder'.
at
System.Reflection.Emit.AssemblyBuilderData.GetInMemoryAssemblyModule()
at System.AppDomain.InternalDefineDynamicAssembly(AssemblyName name,
AssemblyBuilderAccess access, String dir, Evidence evidence,
PermissionSet requiredPermissions, PermissionSet optionalPermissions,
PermissionSet refusedPermissions, StackCrawlMark& stackMark,
IEnumerable`1 unsafeAssemblyAttributes)
at System.AppDomain.DefineDynamicAssembly(AssemblyName name,
AssemblyBuilderAccess access)
at Python.Runtime.CodeGenerator..cctor()
--- End of inner exception stack trace ---
at Python.Runtime.DelegateManager.GetDispatcher(Type dtype)
at Python.Runtime.DelegateManager.GetDelegate(Type dtype, IntPtr
callable)
at Python.Runtime.EventObject.AddEventHandler(IntPtr target, IntPtr
handler)
at Python.Runtime.EventBinding.nb_inplace_add(IntPtr ob, IntPtr arg)
****************************
**** 64-bit, test_event ****
Unhandled Exception: System.TypeInitializationException: The type
initializer for 'Python.Runtime.CodeGenerator' threw an exception. --->
System.InvalidCastException: Unable to cast object of type
'System.Reflection.Module' to type
'System.Reflection.Emit.ModuleBuilder'.
at
System.Reflection.Emit.AssemblyBuilderData.GetInMemoryAssemblyModule()
at System.AppDomain.InternalDefineDynamicAssembly(AssemblyName name,
AssemblyBuilderAccess access, String dir, Evidence evidence,
PermissionSet requiredPermissions, PermissionSet optionalPermissions,
PermissionSet refusedPermissions, StackCrawlMark& stackMark,
IEnumerable`1 unsafeAssemblyAttributes)
at System.AppDomain.DefineDynamicAssembly(AssemblyName name,
AssemblyBuilderAccess access)
at Python.Runtime.CodeGenerator..cctor()
--- End of inner exception stack trace ---
at Python.Runtime.CodeGenerator.DefineType(String name, Type
basetype)
at Python.Runtime.DelegateManager.GetDispatcher(Type dtype)
at Python.Runtime.DelegateManager.GetDelegate(Type dtype, IntPtr
callable)
at Python.Runtime.EventObject.AddEventHandler(IntPtr target, IntPtr
handler)
at Python.Runtime.EventBinding.nb_inplace_add(IntPtr ob, IntPtr arg)
****************************
**** 32-bit, test_delegate ****
Unhandled Exception: System.TypeInitializationException: The type
initializer for 'Python.Runtime.CodeGenerator' threw an exception. --->
System.InvalidCastException: Unable to cast object of type
'System.Reflection.Module' to type
'System.Reflection.Emit.ModuleBuilder'.
at
System.Reflection.Emit.AssemblyBuilderData.GetInMemoryAssemblyModule()
at System.AppDomain.InternalDefineDynamicAssembly(AssemblyName name,
AssemblyBuilderAccess access, String dir, Evidence evidence,
PermissionSet requiredPermissions, PermissionSet optionalPermissions,
PermissionSet refusedPermissions, StackCrawlMark& stackMark,
IEnumerable`1 unsafeAssemblyAttributes)
at System.AppDomain.DefineDynamicAssembly(AssemblyName name,
AssemblyBuilderAccess access)
at Python.Runtime.CodeGenerator..cctor()
--- End of inner exception stack trace ---
at Python.Runtime.DelegateManager.GetDispatcher(Type dtype)
at Python.Runtime.DelegateManager.GetDelegate(Type dtype, IntPtr
callable)
at Python.Runtime.DelegateObject.tp_new(IntPtr tp, IntPtr args,
IntPtr kw)
at e__NativeCall.Call_3(IntPtr , IntPtr , IntPtr , IntPtr )
at Python.Runtime.MetaType.tp_call(IntPtr tp, IntPtr args, IntPtr kw)
****************************
**** 64-bit, test_delgate ****
Unhandled Exception: System.TypeInitializationException: The type
initializer for 'Python.Runtime.CodeGenerator' threw an exception. --->
System.InvalidCastException: Unable to cast object of type
'System.Reflection.Module' to type
'System.Reflection.Emit.ModuleBuilder'.
at
System.Reflection.Emit.AssemblyBuilderData.GetInMemoryAssemblyModule()
at System.AppDomain.InternalDefineDynamicAssembly(AssemblyName name,
AssemblyBuilderAccess access, String dir, Evidence evidence,
PermissionSet requiredPermissions, PermissionSet optionalPermissions,
PermissionSet refusedPermissions, StackCrawlMark& stackMark,
IEnumerable`1 unsafeAssemblyAttributes)
at System.AppDomain.DefineDynamicAssembly(AssemblyName name,
AssemblyBuilderAccess access)
at Python.Runtime.CodeGenerator..cctor()
--- End of inner exception stack trace ---
at Python.Runtime.CodeGenerator.DefineType(String name, Type
basetype)
at Python.Runtime.DelegateManager.GetDispatcher(Type dtype)
at Python.Runtime.DelegateManager.GetDelegate(Type dtype, IntPtr
callable)
at Python.Runtime.DelegateObject.tp_new(IntPtr tp, IntPtr args,
IntPtr kw)
at e__NativeCall.Call_3(IntPtr , IntPtr , IntPtr , IntPtr )
at Python.Runtime.MetaType.tp_call(IntPtr tp, IntPtr args, IntPtr kw)
****************************
-----Original Message-----
From: Christian Heimes [mailto:lists at cheimes.de]
Sent: Sunday, November 18, 2007 5:38 PM
To: John Burnett
Cc: Brian Lloyd
Subject: Re: [Python.NET] Added 64-bit support, delegates/events broken?
John Burnett wrote:
> I've made a few changes necessary to make python.net 64-bit
compatible. I can check in the changes on Monday (unless I need an
account set up first?) I also fixed a broken test case wrt. exceptions.
Neither Brian nor me have a 64bit CPU. Although the code tries to be
64bit compatible neither of us is able to verify the code. Thanks for
your work! :)
You cannot check in the code yourself. Can you please make two patches,
one for the 64bit and one for the unit tests, and post them in the bug
and feature tracker at sf.net?
Brian: I still don't have developer and technician roles in the bug
tracker. Can you please raise my level for the tracker, too?
> That said, I'm getting unrelated hard crashes when running the test
cases for either events or delegates (i.e. the whole test harness
crashes out). Is anyone else seeing this, or is it something peculiar
with my setup (it's happening in both 32 and 64 bit Vista, compiled
under VS2005). I can post details on Monday if necessary...
I haven't seen hard crashes for a while. I'm using VS 2005 and Mono
1.2.4 for testing. Please post some details.
Christian
More information about the PythonDotNet
mailing list