From nobody Thu May 19 15:01:24 2022 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E82E11B338EF for ; Thu, 19 May 2022 15:01:24 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4L3tNN0vggz4gJJ for ; Thu, 19 May 2022 15:01:24 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 00DAF1FC25 for ; Thu, 19 May 2022 15:01:24 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 24JF1Nbc018593 for ; Thu, 19 May 2022 15:01:23 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 24JF1NGk018592 for bugs@FreeBSD.org; Thu, 19 May 2022 15:01:23 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 264081] sort -s (i.e., stable sort) does not work correctly Date: Thu, 19 May 2022 15:01:24 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: gnu X-Bugzilla-Version: 13.1-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: kyle@kneisl.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652972484; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Qv2TE03cbPgfqwxnpFDCBTej+s8ofBTeJLFZRkmFO+Q=; b=sFDvPDcbp+9CxF1y0vMIbb/dzYY/ny+PKRAbmtvnL+xQOZk3Yn+Y8JzGk7U7oORlJoCdjv p0SQR/2dl407J7++5QYspctA8vDRN217Rt/LNe3hJ0484cSuKsWVg1sk63xYCxK3MzJJR+ kvt4OaNKNE/a8/3aUOu37mZutRAj55SaazkmB7eMO/Ri/MUJOJl842uzb8dNs0n0xeM2Xb Ef4a2AiPvCVHzFf0usjvOqHKoXB1Dwj0ce0QRppjxvEn7HJdV04TlWAGRz2vZVj3ngMo0J KbOURT2Rv7ksWbIEZAzy5DeQjAbbLpbe992AK7axxyA3wi01rFV+OpJAiylLAA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652972484; a=rsa-sha256; cv=none; b=oFYQlnlcuWGXj7Rqdh6HitgCJl60rJ6zLOjwKtSxUlsI78NO2ObheV5vj+qdnwV0DYDDD5 6UeUSbaoVZx1FHbY12AuyrYrfxaLImGYwFQQplpmEjkldLhVeYZxu0TokRQ5a8d3x8liFV a8EkIo2Ov1vL4VBqyP7lUFXU6m8zy2R0UXfw621WAup/9OVvNC6RCAaWnemPrIZdoiVS4R 41SWA9LHo7wfjECuaYkcNIHJc3hzaeku1oUiR5/+RXD9azZsRKxipORLKA07rORpWlUVH8 IJaZKsEli74oA2zxvEI6eULPSQ9cVeDa2Xe9TKadFIu8Ovtqe2z7LVzzu9DNxw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D264081 Bug ID: 264081 Summary: sort -s (i.e., stable sort) does not work correctly Product: Base System Version: 13.1-RELEASE Hardware: amd64 OS: Any Status: New Severity: Affects Many People Priority: --- Component: gnu Assignee: bugs@FreeBSD.org Reporter: kyle@kneisl.org Created attachment 234035 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D234035&action= =3Dedit chrony "measurements.txt" log output sample Interestingly, the -s option for sort(1), which is supposed to be a "stable sort", i.e., preserving the order of items in the original stream when they have equal sort keys, apparently does not work as intended. I haven't exhausted all of the possibilities, but, in my test files over here, it SEE= MS to work for -k1, when the sort key is the first line item. However, it does not seem to work in other cases. I have included a bit of my chronyd measurements log, and you can easily reproduce. Note that in the attached file logsample, containing 32 lines in chronologi= cal order for chrony measurements, the following command: cat logsample | sort -s -k4 produce equally keyed items (in fact, all items have equal keys in the 4th = line item) that are now *NOT* in the same order as the original stream, so that = this sort is NOT stable as expected with -s. For example: 2022-05-19 13:52:03 192.168.1.197 N 2 111 111 1111 9 9 0.17 2.584e-0= 4=20 6.596e-04 3.849e-06 2.155e-02 2.243e-03 98028536 4I D K 2022-05-19 13:43:30 192.168.1.197 N 2 111 111 1111 9 9 0.21 4.559e-0= 4=20 5.857e-04 3.849e-06 2.155e-02 1.694e-03 98028536 4I D K 2022-05-19 08:32:09 192.168.1.197 N 2 111 111 1111 9 9 0.30 4.185e-0= 5=20 6.944e-04 3.849e-06 2.234e-02 3.952e-03 98028536 4I D K 2022-05-19 08:40:46 192.168.1.197 N 2 111 111 1111 9 9 0.51 -4.130e-0= 5=20 5.296e-04 3.849e-06 2.234e-02 4.471e-03 98028536 4I D K But,=20 cat logsample | sort -s -k1 works fine. I did just upgrade everything to 13.1 yesterday, so I'm not sure how far ba= ck this goes, or if it's new. --=20 You are receiving this mail because: You are the assignee for the bug.=