[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#18361: New 'sort' implementation can crash Emacs

From: Dmitry Antipov
Subject: bug#18361: New 'sort' implementation can crash Emacs
Date: Sat, 30 Aug 2014 09:07:46 +0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0

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 ()
  (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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]