discuss-gnustep
[Top][All Lists]
Advanced

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

Re: PyObjc/class_copyMethodList


From: Gregory Casamento
Subject: Re: PyObjc/class_copyMethodList
Date: Fri, 16 Apr 2021 08:50:49 -0400


Please feel free to do so!  I'm very excited to see the change.  The best person to ask about libobjc2 is David Chisnall.

On Thu, Apr 15, 2021 at 9:39 AM Alexandra Beebe <mischievous.demon@gmail.com> wrote:
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


--
Gregory Casamento
GNUstep Lead Developer / OLC, Principal Consultant
http://www.gnustep.org - http://heronsperch.blogspot.com
https://www.patreon.com/bePatron?u=352392 - Become a Patron
https://gf.me/u/x8m3sx - My GNUstep GoFundMe

reply via email to

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