bugGNUstep - Bugs: bug #34191, +bundleForClass: doesn't with...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #34191: +bundleForClass: doesn't with framework bundles

Submitted by:  Quentin Mathé <qmathe>
Submitted on:  Fri 02 Sep 2011 07:57:43 AM UTC  
 
Category: MakefilesSeverity: 4 - Important
Item Group: BugStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Tue 21 Oct 2014 08:13:10 AM UTC, comment #4:

With no response by the original submitter, I'm going to close the case.

Riccardo Mottola <rmottola>
Project Member
Mon 02 Jul 2012 09:09:15 AM UTC, comment #3:

I've just attempted a fix for this ... but I don't have any testcase for it ...

Richard Frith-Macdonald <CaS>
Project Member
Sun 01 Jul 2012 10:47:57 PM UTC, comment #2:

Has there been any further progress on this?

Gregory John Casamento <gcasa>
Project Administrator
Sat 03 Sep 2011 02:47:22 AM UTC, comment #1:

This problem appears to be a bit more complicated than +bundleForClass not working.

The cause is +[NSBundle intialize] not finding the NSFramework_EtoileUI class, which doesn't exist at the time it was called. NSBundle builds a list of frameworks when its +intialize method is called, by searching the runtime for classes that begin with "NSFramework_". These classes are placeholders, generated by gnustep-make, that indicate that a shared library is in fact a framework, and like bundles, can contain resources to be loaded.

In this case, EtoileUI was accidentally triggering the +[NSBundle intialize] method before NSFramework_EtoileUI had been loaded. It does this by calling GNUstep classes (such as NSString and NSSet) from a +load method in a category on NSView. +load methods are implemented by creating constructor functions i.e. _attribute_((constructor)) that are called when a shared library is loaded. This is a problem because these constructor functions also seem to be used to register classes with the runtime when a shared library is loaded.

+load is not supposed to be used for anything other than very simple, C-based intialisation, because as documented here [1], +load is not guaranteed to be called at a time when other classes are ready. By doing this, NSBundle initializes before all other classes are loaded and builds an incomplete framework list.

The correct solution is not use +load for anything other than calling classes in the same file, but this still means that NSBundle is vulnerable to being initialised to early and building incomplete framework meta-data. NSBundle cannot easily convert its initialisation to a +load method either, which would prevent the issue from occurring.

[1] http://gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/What-you-can-and-what-you-cannot-do-in-_002bload.html#What-you-can-and-what-you-cannot-do-in-_002bload

Chris Armstrong <carmstrong>
Fri 02 Sep 2011 07:57:43 AM UTC, original submission:

Linux Ubuntu 10.04 x86 32 bits
Clang 3.0 trunk
libobjc2 r33786
GNUstep core r33803

NSBundle is unable to look up a framework based on a class that belongs to it. The problem could be in a makefile change I made, but I doubt it. This was working correctly around two or three months ago I think.

I tried to track down the issue a bit. I have found that +[NSBundle bundleForLibrary:version:] is looking for a directory such as /Local/Library/Libraries/EtoileUI/Versions which doesn't exist. There is even no EtoileUI directory in the /Local/Library/Libraries. In /Local/Library/Frameworks, the EtoileUI.framework is properly installed with subdirectories such as Resources and Versions. So it looks like that either Base doesn't look into the EtoileUI.framework, or Make doesn't make a symbolic link at /Local/Library/Libraries/EtoileUI pointing to /Local/Library/Frameworks/EtoileUI.framework.

Cheers,
Quentin.

Quentin Mathé <qmathe>
Project Member

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rmottola (Posted a comment)
  • -unavailable- added by CaS (Posted a comment)
  • -unavailable- added by gcasa (Posted a comment)
  • -unavailable- added by carmstrong (Posted a comment)
  • -unavailable- added by qmathe (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 21 Oct 2014 08:15:04 AM UTCrmottolaOpen/ClosedIn Test=>Closed
    Mon 02 Jul 2012 09:09:15 AM UTCCaSStatusNone=>Fixed
      Open/ClosedOpen=>In Test

    Back to the top


    Powered by Savane 3.1-cleanup1