bugGNUstep - Bugs: bug #50895, Change to size of...

 
 

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

bug #50895: Change to size of NSComparisonResult breaks custom sort from 1.24.8 to 1.24.9

Submitted by:  David Lobron <dlobron>
Submitted on:  Fri 28 Apr 2017 08:10:03 PM UTC  
 
Category: Base/FoundationSeverity: 3 - Normal
Item Group: BugStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Mon 08 May 2017 01:49:45 PM UTC, comment #3:

Thanks, Richard- I agree. I didn't realize that the latest version had moved past 1.24.x (we are jumping over a few versions in our upgrade). We actually have another system-wide upgrade coming, so we can do a rebuild of all programs that use the shared library at the time time we upgrade, which should get us past this problem. Thank you again for your response to this.

David Lobron <dlobron>
Sat 06 May 2017 11:20:21 AM UTC, comment #2:

You are right, this is definitely a bug and shouldn't have happened.

But it's in the previous release of gnustep-base (from over a year ago), so reverting the change doesn't seem to be an option. Also the current release (1.25.0) does have an updated library version and could be considered to have fixed the issue already.

I don't know what could/should be done about 1.24.9 itself; accordingly, I'm closing this issue as fixed, but if you have a suggestion about what could be done to improve the situation I'd be happy to hear it.

Richard Frith-Macdonald <CaS>
Project Member
Fri 28 Apr 2017 08:12:52 PM UTC, comment #1:

Oops, correction: the first sentence should read "custom sort header built with the 1.24.8 headers failed when we ran then with the 1.24.9 runtime").

David Lobron <dlobron>
Fri 28 Apr 2017 08:10:03 PM UTC, original submission:

When we tried to migrate our company's software from gnustep-base-1.24.8 to 1.24.9, we found that custom sort routines built with the 1.24.9 headers failed when we ran them with the 1.24.9 runtime. The sort code was OK if built with 1.24.9.

We traced this to the fact that the enum type used for NSComparisonResult changed from 4 bytes to 8. We are building in 64-bit mode (-m64) on GNU/Linux. The exact point of failure is in GSTimSort.m, at line 350: it compares the result of GSCompareUsingDescriptorOrComparator to the NSOrderedAscending constant, and the comparison returns false when it should return true, because it's expecting 8 bytes and the function is returning 2^^32 - 1 (set in the lower-order 4 bytes), which of course returns false when compared with -1.

This means that code compiled against an previous version of gnustep will fail to do custom sort routines when run in 1.24.9. This seems like a larger ABI change than we would expect from a minor version bump. Was this intentional? If not, could we restore the old definition, at least pending more notice?

I've attached a program that reproduces the bug. When built and run with either 1.24.8 or 1.24.9, it sorts correctly:

2017-04-28 19:41:32.645 mincase[28527:28527] Sorted array contents:
2017-04-28 19:41:32.646 mincase[28527:28527] 0
2017-04-28 19:41:32.646 mincase[28527:28527] 1
2017-04-28 19:41:32.646 mincase[28527:28527] 2
2017-04-28 19:41:32.646 mincase[28527:28527] 5

but when built with 1.24.8 and run with 1.24.9, the sort fails:

2017-04-28 19:48:59.271 mincase[7338:7338] Sorted array contents:
2017-04-28 19:48:59.271 mincase[7338:7338] 0
2017-04-28 19:48:59.271 mincase[7338:7338] 1
2017-04-28 19:48:59.271 mincase[7338:7338] 5
2017-04-28 19:48:59.271 mincase[7338:7338] 2

David Lobron <dlobron>

 

Attached Files
file #40530:  mincase.m added by dlobron (793B - application/octet-stream - Minimal reproducer)

 

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 dlobron (Submitted the item)
  • -unavailable- added by dlobron (Including Larry Campbell)
  • -unavailable- added by dlobron (Including Larry Campbell)
  •  

    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
    Sat 06 May 2017 11:20:21 AM UTCCaSStatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Fri 28 Apr 2017 08:10:03 PM UTCdlobronAttached File-=>Added mincase.m, #40530
      Carbon-Copy-=>Added -unavailable-
      Carbon-Copy-=>Added -unavailable-

    Back to the top


    Powered by Savane 3.1-cleanup1