You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just ran into the issue that a when a callback is passed to my C land driver that is a classmethod, the object passed is not callable, but of the type mp_type_slice. And thus calling it will raise an exception.
I can make wrapper functions for the classmethod functions to work around the issue, but I was wondering it was solvable in C as well.
I am still running a now rather aged (like wine !) micropython-1.9.3 (since I did quite some modifications to it, it is not easy to just replace it by a more recent version). I tried to look at the old forum to see if someone else might have already dealt with this as I cannot be the first one to run into this but it is apparently down.
Here in the discussions the issue does not yet have seem to come up (so maybe it is not a problem anymore in recent versions ?)
Any pointers or references in the right direction are greatly appreciated ...
EDIT: after looking some more into it, I might actually be having a memory corruption issue rather than a problem with classmethods, as the object passed to C land in the callback is initially of the type mp_type_bound_meth.
But by the time I want to call the callback it has become something of the type mp_type_slice.
So that seems suspicious.
I am guessing the memory space used for the callback object gets reclaimed by the GC because the callback pointer is not in an area scanned by the GC. And maybe wasn't a problem when I was passing a normal function since that one is automatically protection ( or something like that, it only became an issue when i made a class method of a previously normal method and it has been in used for years already ).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I just ran into the issue that a when a callback is passed to my C land driver that is a classmethod, the object passed is not callable, but of the type mp_type_slice. And thus calling it will raise an exception.
I can make wrapper functions for the classmethod functions to work around the issue, but I was wondering it was solvable in C as well.
I am still running a now rather aged (like wine !) micropython-1.9.3 (since I did quite some modifications to it, it is not easy to just replace it by a more recent version). I tried to look at the old forum to see if someone else might have already dealt with this as I cannot be the first one to run into this but it is apparently down.
Here in the discussions the issue does not yet have seem to come up (so maybe it is not a problem anymore in recent versions ?)
Any pointers or references in the right direction are greatly appreciated ...
EDIT: after looking some more into it, I might actually be having a memory corruption issue rather than a problem with classmethods, as the object passed to C land in the callback is initially of the type mp_type_bound_meth.
But by the time I want to call the callback it has become something of the type mp_type_slice.
So that seems suspicious.
I am guessing the memory space used for the callback object gets reclaimed by the GC because the callback pointer is not in an area scanned by the GC. And maybe wasn't a problem when I was passing a normal function since that one is automatically protection ( or something like that, it only became an issue when i made a class method of a previously normal method and it has been in used for years already ).
Beta Was this translation helpful? Give feedback.
All reactions