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

 
 

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

bug #30040: Portability issue with binary property list

Submitted by:  Wolfgang Lux <wlux>
Submitted on:  Wed 02 Jun 2010 08:41:04 PM UTC  
 
Category: Base/FoundationSeverity: 3 - Normal
Item Group: BugStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

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>
Project 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>
Project 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>

 

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

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 16 Jun 2010 07:02:49 AM UTCCaSOpen/ClosedIn Test=>Closed
    Tue 08 Jun 2010 07:10:37 PM UTCCaSStatusNone=>Fixed
      Open/ClosedOpen=>In Test
    Wed 02 Jun 2010 08:41:04 PM UTCwluxAttached File-=>Added producer.m, #20678
      Attached File-=>Added consumer.m, #20679

    Back to the top


    Powered by Savane 3.1-cleanup1