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

Group
 
 

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

Submitter:  Quentin Mathé <qmathe>
Submitted:  Fri 02 Sep 2011 07:57:43 AM UTC
   
 
Category:  Makefiles Severity:  4 - Important
Item Group:  Bug Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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>
Group Member
Sun 01 Jul 2012 10:47:57 PM UTC, comment #2: 

Has there been any further progress on this?

Gregory John Casamento <gcasa>
Group 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>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-10-21 rmottola Open/ClosedIn Test Closed
    2012-07-02 CaS StatusNone Fixed
        Open/ClosedOpen In Test

    Back to the top

    Powered by Savane 3.13-aa77.
    Corresponding source code