discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PyObjc/class_copyMethodList


From: Alexandra Beebe
Subject: PyObjc/class_copyMethodList
Date: Thu, 15 Apr 2021 08:38:51 -0500

For some reason my spouse and I wanted to get pyobjc working with gnustep.  I 
think I found a bug in the objc2 runtime... with "Method * 
class_copyMethodList(Class cls, unsigned int *outCount)". 

Where pyobjc is using it like so 
"pyobjc/pyobjc-core/Modules/objc/objc-class.m::metaclass_dir : 1102" 

        
  while (cls != NULL) {
      /* Now add all method names */
      methods = class_copyMethodList(object_getClass(cls), &method_count);
      for (i = 0; i < method_count; i++) {



What's happening is "pyobjc" is not clearing out the "method_count" before 
calling the function.  When "class_copyMethodList" returns NULL for the 
methods, the method_count contains the stack garbage from the previous call to 
the function...


I can fix it in pyobjc by clearing the method_count before all the calls, but I 
suspect that the libobjc::runtime.c should be clearing the value before doing 
the "CHECK_ARG" call.  

I will be happy to fork the github repos, make the fix, do a push, then submit 
a pull request.  



Alexandra


reply via email to

[Prev in Thread] Current Thread [Next in Thread]