bug-gnustep
[Top][All Lists]
Advanced

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

Spurious Crashes with bundle loading...


From: Roland Schwingel
Subject: Spurious Crashes with bundle loading...
Date: Mon, 05 May 2003 14:16:12 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3) Gecko/20030312

Hi...

We are using bundleloading very intensive and our applications are typically 
loading >100 bundles.
Principally everything works fine but from time to time it crashes while 
loading bundles on windows.
(especially when running the application in gdb)

I debugged into it and found that the problem is triggered by objc-load.m in 
gnustep-base.
There is a function objc_invalidate_dtable() which invalidates the classes 
dispatch tables after loading a bundle.
(I think it is ment to integrate categories from the bundles)

I found out that sarray_free() tries to access a bucket from a sparse array 
which adress is no longer valid.

Currently the function looks like this:
static void
objc_invalidate_dtable(Class class)
{
#ifndef NeXT_RUNTIME
  Class s;

  if (class->dtable == objc_get_uninstalled_dtable())
    {
      return;
    }

  sarray_free(class->dtable);
  __objc_install_premature_dtable(class);
  for (s = class->subclass_list; s; s = s->sibling_class)
    {
      objc_invalidate_dtable(s);
    }
#endif
}

If I turned the rekursion around my spurious crashes appear to fade away.
(started my app 60 times without a crash (before I got at least one crash every 
8 tries))
The new functions looks this way:

static void
objc_invalidate_dtable(Class class)
{
#ifndef NeXT_RUNTIME
  Class s;

  if (class->dtable == objc_get_uninstalled_dtable())
    {
      return;
    }

  for (s = class->subclass_list; s; s = s->sibling_class)
    {
      objc_invalidate_dtable(s);
    }

  sarray_free(class->dtable);
  __objc_install_premature_dtable(class);

#endif
}

Now the functions decends first into the complete tree before setting the 
premature new dispatch table in the affected classes...

Well this appears to work, but I have also studied the source of the gnu objc 
runtime and experimentally completely removed the invalidation in objc-load.m. 
Of course my bug was gone and I can't find any other problem resulting from the 
removing of the invalidation. All runs very well.

I know the invalidation is done because of integrating the categories contained 
in the bundles. But to me it shows that the objc-runtime already takes care of 
this task on its own. My bundles are containing lots of categories, and it 
appears they get correctly registered without invalidating the dispatch table.

So is this code ancient and could maybe removed? Why is this piece of code 
here? Which task has it?

If it is not needed it should IMHO be removed. If not maybe someone could apply 
my patch?

Thanks,

Roland





reply via email to

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