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

From: Dmitry Antipov <[email-masked]>
Date: Sat, 30 Aug 2014 02:47:01 +0400

On 08/30/2014 01:24 AM, Paul Eggert wrote:

> The new implementation of 'sort' in the trunk invokes qsort (or qsort_r),
> but these functions have undefined behavior if the comparison function is
> ill-behaved.  Since the comparison predicate is user-defined, this means
> a bad user-supplied comparison function could crash Emacs.

I don't see how is that possible if we operate on a correctly initialized
vector and sort_vector_predicate is a valid function accepting 2 arguments.
Can you provide an example?  Is that just a poor property of the particular
qsort(_r) implementation?

Dmitry