From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Antipov Newsgroups: gmane.emacs.bugs Subject: bug#18361: New 'sort' implementation can crash Emacs Date: Sat, 30 Aug 2014 09:07:46 +0400 Message-ID: <54015C22.5030108@yandex.ru> References: <5400EFA5.6090902@cs.ucla.edu> <540102E5.6040404@yandex.ru> <5401079D.7070505@cs.ucla.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1409375307 7246 80.91.229.3 (30 Aug 2014 05:08:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 30 Aug 2014 05:08:27 +0000 (UTC) Cc: 18361@debbugs.gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Aug 30 07:08:21 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XNatg-0003IB-FG for geb-bug-gnu-emacs@m.gmane.org; Sat, 30 Aug 2014 07:08:20 +0200 Original-Received: from localhost ([::1]:45231 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNatf-0004Te-PG for geb-bug-gnu-emacs@m.gmane.org; Sat, 30 Aug 2014 01:08:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNatV-0004Rp-US for bug-gnu-emacs@gnu.org; Sat, 30 Aug 2014 01:08:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XNatO-0005pH-TH for bug-gnu-emacs@gnu.org; Sat, 30 Aug 2014 01:08:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:34144) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNatO-0005or-NY for bug-gnu-emacs@gnu.org; Sat, 30 Aug 2014 01:08:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XNatN-00048R-U7 for bug-gnu-emacs@gnu.org; Sat, 30 Aug 2014 01:08:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Antipov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 30 Aug 2014 05:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18361 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 18361-submit@debbugs.gnu.org id=B18361.140937527915887 (code B ref 18361); Sat, 30 Aug 2014 05:08:01 +0000 Original-Received: (at 18361) by debbugs.gnu.org; 30 Aug 2014 05:07:59 +0000 Original-Received: from localhost ([127.0.0.1]:53941 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XNatK-000489-Vx for submit@debbugs.gnu.org; Sat, 30 Aug 2014 01:07:59 -0400 Original-Received: from forward1h.cmail.yandex.net ([87.250.230.16]:60278) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XNatF-00047t-Nb for 18361@debbugs.gnu.org; Sat, 30 Aug 2014 01:07:55 -0400 Original-Received: from smtp1h.mail.yandex.net (smtp1h.mail.yandex.net [84.201.187.144]) by forward1h.cmail.yandex.net (Yandex) with ESMTP id 20D7D1304; Sat, 30 Aug 2014 09:07:47 +0400 (MSK) Original-Received: from smtp1h.mail.yandex.net (localhost [127.0.0.1]) by smtp1h.mail.yandex.net (Yandex) with ESMTP id CBB6B1340777; Sat, 30 Aug 2014 09:07:46 +0400 (MSK) Original-Received: from unknown (unknown [37.139.80.10]) by smtp1h.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id vTjqd1BbvS-7kReWNIS; Sat, 30 Aug 2014 09:07:46 +0400 (using TLSv1.2 with cipher AES128-SHA (128/128 bits)) (Client certificate not present) X-Yandex-Uniq: c59c0833-a2ec-4b4d-b975-0c96936739fd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1409375266; bh=e4iICvOGWZa/HlXE1EuzW3DT91byPIHsYhWxNDZRhW0=; h=Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject: References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=ojgBaTNJKKbGxrlr4VxIFNcTv7WYA2pt5jCsCh0Q17dx+1ecOupqN3KX9rZSmLogt hz4Q+RDZmoCdTjxvbGs3y9/aGMyiMcdmksVp1Z6l922Go/9FVUZwWihoGETwRfeWqR ASwC2X3aTJjIZfrcdOEUOLccp+uJl+gp0eKTwdJc= Authentication-Results: smtp1h.mail.yandex.net; dkim=pass header.i=@yandex.ru User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 In-Reply-To: <5401079D.7070505@cs.ucla.edu> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:92840 Archived-At: On 08/30/2014 03:07 AM, Paul Eggert wrote: > Sure, a comparison function that returns a new random value every > time you call it. Such a function is most likely not well formed > that is, it most likely does not define a total order. If an undefined behavior doesn't cause crash, I don't see a problem if this is well-documented (probably in lispref). I gave this function a solid run on GNU/Linux (glibc 2.18) and FreeBSD 10.0, and was unable to crash: (defun sort-run () (interactive) (let* ((max 1000000) (size 1000) (p (make-progress-reporter "Sorted: " 0 max))) (dotimes (loops max) (let ((v (make-vector size 0))) (dotimes (i size) (aset v i (% (random) (* size 2)))) (sort v (lambda (x y) (random))) (progress-reporter-update p loops))) (progress-reporter-done p))) I don't have any reasons to not trust in your experience, but I'm really curious to look at the real example crashing qsort(_r) due to ill-formed comparison function. Dmitry