/usr/bin/sort may be incorrect

Shigeharu TAKENO shige at iee.niit.ac.jp
Thu Mar 31 04:46:31 UTC 2016


shige 03/31 2016
----------------

I wrote:
|   command line "sort -k3n -k1n file" : 
|     FreeBSD/i386    : succeed (output sorted lines) 
|     FreeBSD/sparc64 : failed  (output no line) 
| 
|   command line "sort -k3n file" : 
|     FreeBSD/i386    : succeed (output sorted lines) 
|     FreeBSD/sparc64 : succeed (output sorted lines) 

|   command line 
|    "( echo 2 5 8 ; echo 2 6 5 ) | sort -n +0 -1 +1 -2 +2 -3 -c" :
|     FreeBSD/i386    : return status 0
|     FreeBSD/sparc64 : return status 255


I found the workaround for the problem:

----- From here -----
--- /usr/src/usr.bin/sort/coll.h.ORG	2016-03-31 13:23:24.226753000 +0900
+++ /usr/src/usr.bin/sort/coll.h	2016-03-31 13:24:23.469436000 +0900
@@ -90,7 +90,11 @@
 struct key_value
 {
 	struct bwstring		*k; /* key string */
+#if 0
 	struct key_hint		 hint[0]; /* key sort hint */
+#else
+	struct key_hint		 hint[1]; /* key sort hint */
+#endif
 };
 
 /*
----- To here -----

The k field of key_value may be overwritten by the hint field
in numcoll_impl(), gnumcoll() and monthcoll() (coll.c), and the
pointer value of k may change to incorrect value.

I could build shells/pdksh and x11-themes/fvwm-themes by new sort
command applied the patch above.

+========================================================+
 Shigeharu TAKENO     NIigata Institute of Technology
                       kashiwazaki,Niigata 945-1195 JAPAN
 shige at iee.niit.ac.jp   TEL(&FAX): +81-257-22-8161
+========================================================+


More information about the freebsd-sparc64 mailing list