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

Group
 
 

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

Submitter:  David Lobron <dlobron>
Submitted:  Fri 28 Apr 2017 08:10:03 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
   

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

 

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

Attach Files:
   
   
Comment:
   

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
  • -email is unavailable- added by CaS (Posted a comment)
  • -email is unavailable- added by dlobron (Submitted the item)
  • -email is unavailable- added by dlobron (Including Larry Campbell)
  • -email is unavailable- added by dlobron (Including Larry Campbell)
  •  

    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
    2017-05-06 CaS StatusNone Fixed
        Open/ClosedOpen Closed
    2017-04-28 dlobron Attached File- Added mincase.m, #40530
        Carbon-Copy- Added -email is unavailable-
        Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code