bugGNUstep - Bugs: bug #30040, Portability issue with binary...

Group
 
 

bug #30040: Portability issue with binary property list

Submitter:  Wolfgang Lux <wlux>
Submitted:  Wed 02 Jun 2010 08:41:04 PM UTC
   
 
Category:  Base/Foundation Severity:  3 - Normal
Item Group:  Bug Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 16 Jun 2010 07:02:50 AM UTC, comment #3: 

The double case was not needed (just the correct single one).
I tidied the code up for 64bit systems.

Richard Frith-Macdonald <CaS>
Group Member
Mon 14 Jun 2010 03:07:06 PM UTC, comment #2: 

The change looks okay to me and works correctly for the few examples I've tested.

P.S.: What is the point of the double cast in markOffset:for:?

Wolfgang Lux <wlux>
Tue 08 Jun 2010 07:10:37 PM UTC, comment #1: 

I changed the code to differentiate between identical numeric values in different classes.  Please take a look and see if you think this is a good fix.

Richard Frith-Macdonald <CaS>
Group Member
Wed 02 Jun 2010 08:41:04 PM UTC, original submission:  

During recent tests I noticed a portability issue where GNUstep writes binary property lists that cannot be read back on OS X. The particular issue is that GNUstep's property list generator unifies integer and floating point numbers with the same numeric value, but OS X is more picky when reading numeric values. E.g., given code like
  [aCoder encodeInt: 42 forKey: 'A'];
  [aCoder encodeFloat: 42 forKey: 'B'];
GNUstep writes only a single (integer) number to the archive. When reading this archive on OS X with the code
  a = [aDecoder decodeIntForKey: 'A'];
  b = [aDecoder decodeFloatForKey: 'B'];
the program will report an exception during the second statement.

I've put together a little test case. Compile the attached producer on GNUstep, run the program and copy the files archive1 and archive2 to OS X. On OS X, compile and run the attached consumer (it expects the two archives in the current directory). It will print the following exceptions:
  Reading archive1 ...
  Exception in consumer.m at line 23: * -[NSKeyedUnarchiver decodeIntForKey:]: value for key (A) is not an integer number
  Reading archive2 ...
  Exception in consumer.m at line 31: * -[NSKeyedUnarchiver decodeFloatForKey:]: value for key (A) is not a float number
  Done

A quick workaround would be to replace the two -indexOfObject: method calls in NSPropertyList.m by -indexOfObjectIdenticalTo:, but this is going to duplicate identical numbers unnecessarily  and may increase the size of saved archives substantially (OS X doesn't seem to work this way).

Wolfgang Lux <wlux>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #20678:  producer.m added by wlux (909B - application/octet-stream)
file #20679:  consumer.m added by wlux (1KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by CaS (Posted a comment)
  • -email is unavailable- added by wlux (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-06-16 CaS Open/ClosedIn Test Closed
    2010-06-08 CaS StatusNone Fixed
        Open/ClosedOpen In Test
    2010-06-02 wlux Attached File- Added producer.m, #20678
        Attached File- Added consumer.m, #20679

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code