discuss-gnustep
[Top][All Lists]
Advanced

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

Re: SeqFault in [NSBundle(Private) _addFrameworkFromClass:]


From: Matt Rice
Subject: Re: SeqFault in [NSBundle(Private) _addFrameworkFromClass:]
Date: Tue, 5 Dec 2006 04:16:49 -0800 (PST)

--- Marc Brünink <mbruen@smartsoft.de> wrote:

> Hi all,
> 
> ok it segfaults in
> len = strlen (frameworkClass->name);
> 
> Marc Brünink wrote:
> > Hi all
> >
> > I'm trying to load a framework in an application.
> Shouldn't be a major 
> > task, but it is :-)
> > I'm getting a segfault in [NSBundle(Private)
> _addFrameworkFromClass:]. 
> > The strange thing about it: I do not have any
> problems using this 
> > framework with another tool.
> >
> > It segfaults at the first use of any Foundation
> code. For example at 
> > the NSLog in: printf("HALLo");
> > fflush(stdout);
> > NSLog(@"main A");
> >
> >
> > Any hints?
> >
> > Thanks
> > Marc
> >
> >

well NSBundle +initialize seems to be more complicated
than neccesary
allocating a 'Class classes[]' then looping over all
the runtime classes adding them to 'classes' array
based on some criteria, then looping over 'classes'
and calling _addFrameworkFromClass:classes[i],
 
that critera includes a call to strlen(class->name)
so i can only assume its something gone awry with that
temporary array as i'd expect it to crash before
getting to _addFrameworkFromClass:, 

i don't see anything wrong with that code though
attached is a patch to get rid of that temporary array
anyways

didn't have any apps using frameworks, or even
frameworks handy so its untested, though it compiles..




 
____________________________________________________________________________________
Want to start your own business?
Learn how on Yahoo! Small Business.
http://smallbusiness.yahoo.com/r-index
Index: Source/NSBundle.m
===================================================================
--- Source/NSBundle.m   (revision 24184)
+++ Source/NSBundle.m   (working copy)
@@ -777,39 +777,16 @@
          }
 #else
          {
-           int i, numBufClasses = 10, numClasses = 0;
-           Class *classes;
-
-           classes = objc_malloc(sizeof(Class) * numBufClasses);
-
            while ((class = objc_next_class(&state)))
              {
                unsigned int len = strlen (class->name);
 
-               if (len > 12 * sizeof(char)
-                 && !strncmp("NSFramework_", class->name, 12))
+               if (len > sizeof("NSFramework_")
+                   && !strncmp("NSFramework_", class->name, 12))
                  {
-                   classes[numClasses++] = class;
+                   [self _addFrameworkFromClass: class];
                  }
-               if (numClasses == numBufClasses)
-                 {
-                   Class *ptr;
-
-                   numBufClasses += 10;
-                   ptr = objc_realloc(classes, sizeof(Class) * numBufClasses);
-
-                   if (!ptr)
-                     break;
-
-                   classes = ptr;
-                 }
              }
-
-           for (i = 0; i < numClasses; i++)
-             {
-               [self _addFrameworkFromClass: classes[i]];
-             }
-           objc_free(classes);
          }
 #endif
 #if 0

reply via email to

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