bugÉtoilé - Bugs: bug #17117, LanguageKit calculates the wrong...

Show feedback again

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

bug #17117: LanguageKit calculates the wrong instance variable offset when parent class is Objective-C and not NSObject

Submitted by:  Christopher Armstrong <carmstrong>
Submitted on:  Sun Nov 21 01:59:50 2010  
Category: LanguageKitSeverity: 4 - Important
Priority: 7 - HighStatus: Ready For Test
Privacy: PublicAssigned to: David Chisnall <theraven>
Open/Closed: OpenOperating System: GNU/Linux

Sun Nov 21 01:59:50 2010, original submission:

In LKObjectSymbolTable, nextOffset is used to work out where to put a new instance variable for a Smalltalk defined class. However, in -[LKObjectSymbolTable setScope:], nextOffset is set to have the same offset as its parent class.

This doesn't work for already-compiled classes that are not the root class, because -setScope: is called from within -initForClass: and this process overrides what it should be. The result is that all subclasses which are pre-compiled end up with a nextOffset equal to that of the root class in the hierarchy (usually NSObject, which gives 4).

Given that -setScope: is public and the scope for a class could easily be redefined, I've attached a patch that uses nextOffset differently. It uses nextOffset as a relative offset instead of an absolute offset for new instance variables within the subclass. This means that a parent class should be able to add new symbols because the instance size and the absolute offset of an instance variable (from -offsetOfIVar:) is calculated after the class structure is set up.

However, it may just be simpler to just not call -setScope: from the constructor.

Christopher Armstrong <carmstrong>
Project Member


Attached Files
file #11305:  languagekit-subclassfix-20101121.diff added by carmstrong (3kB - application/octet-stream - A patch that resolves the issue, although it is more complex than just not calling -setScope:)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by carmstrong (Submitted the item)
  • -unavailable- added by carmstrong

    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.


    Error: not logged in



    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed Dec 15 09:48:24 2010carmstrongStatusIn Progress=>Ready For Test
    Sun Nov 21 01:59:50 2010carmstrongAttached File-=>Added languagekit-subclassfix-20101121.diff, #11305
      Carbon-Copy-=>Added carmstrong
    Show feedback again

    Back to the top

    Powered by Savane 3.1-cleanup