Python type object for Sub class gets an unknown extra field of size IntPtr.Size, causing it to be larger than its base type object (reflected) System.Exception.
@amos402 not exactly sure what you mean. The reflected System.Exception should already have a slot for GCHandle. If that would be the reason, size of Sub would be equal to size of System.Exception, but it is not.
@lostmsu@amos402 I just took Amos's interop changes from the soft shutdown branch and applied them to master, and this issue goes away. I'll submit a PR soon with this change, even if it doesn't fix my PyType_FromSpec it could still make the soft shutdown branch easier to review without these changes
Activity
lostmsu commented on Sep 11, 2020
It seems that the reason is that System.Exception has no weak list associated with it:
amos402 commented on Sep 11, 2020
Because it used tp_basicsize as the slot to save GCHandle, you can test it on soft-shutdown branch, it should be fine.
https://github.com/amos402/pythonnet/blob/12c0206b94173935864e0434ec22898753ffb6b5/src/runtime/interop.cs#L116-L117
I changed the slot.
lostmsu commented on Sep 11, 2020
@amos402 not exactly sure what you mean. The reflected System.Exception should already have a slot for GCHandle. If that would be the reason, size of Sub would be equal to size of System.Exception, but it is not.
amos402 commented on Sep 11, 2020
Trust me, it fixed.
The reason is as I said. The size of Sub come from type(System.Exception)->tp_basicsize, they're not equal.
koubaa commented on Sep 13, 2020
@lostmsu @amos402 I just took Amos's interop changes from the soft shutdown branch and applied them to master, and this issue goes away. I'll submit a PR soon with this change, even if it doesn't fix my PyType_FromSpec it could still make the soft shutdown branch easier to review without these changes
koubaa commented on Oct 24, 2020
Fixed in master