-
Notifications
You must be signed in to change notification settings - Fork 748
apply amos interop changes from soft shutdown #1219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ef44edd
to
630da19
Compare
src/runtime/interop.cs
Outdated
|
||
private static int BaseOffset(IntPtr type) | ||
{ | ||
Debug.Assert(type != IntPtr.Zero); | ||
int typeSize = Marshal.ReadInt32(type, TypeOffset.tp_basicsize); | ||
Debug.Assert(typeSize > 0 && typeSize <= ExceptionOffset.Size()); | ||
Debug.Assert(typeSize > 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, the assert should stay. This PR does not address it, but probably solves the problem @koubaa has.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The checking of typeSize <= ExceptionOffset.Size()
is totally a wrong idea, there's no connection between them. Why an other object size whould relates to an exception object size.
You can simply make it lager than that size by
class A(B, C, D, E, F, G): pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amos402 if I remember correctly, BaseOffset
is only used for reflections of .NET classes created by Python.NET. Right now there are only two kinds of them: System.Exception
and everything derived from it, that end up deriving Python's builtins.BaseException
or builtins.Exception
, and every other .NET type, which end up deriving from builtins.object
. Within those two categories each of the types has identical structure, and the ones derived from Exception
just happen to be larger.
When Python class is inherited from a reflected .NET class via single inheritance, and has no extra low-level PyType stuff defined explicitly, I see no reason for its objects to be larger, than corresponding base class objects. Hence all such types should have either the same size as reflected System.Object
or as reflected System.Exception
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@koubaa I am fine with this PR without the check removal.
Codecov Report
@@ Coverage Diff @@
## master #1219 +/- ##
=======================================
Coverage 86.25% 86.25%
=======================================
Files 1 1
Lines 291 291
=======================================
Hits 251 251
Misses 40 40
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
fc8cdb7
to
5ef0adf
Compare
5ef0adf
to
7f576cf
Compare
@amos402 @koubaa the fix is still incomplete. It places For example, on Windows x64 Python 3.8 an instance of PyType is 880 bytes long. An instance of pythonnet/src/runtime/metatype.cs Line 122 in 022be19
Where it writes the To fix this it might be sufficient to increase |
It allocated the space, you can check |
Fixes #1218
Changes taken from @amos402 soft shutdown branch
CHANGELOG