Subject: bug#11077: 24.0.94; avl-tree--enter-balance: (wrong-type-argument arrayp nil)

From: Stefan Monnier <[email-masked]>
Date: Tue, 27 Mar 2012 16:44:18 -0400

>> I have to run the body of the outer loop multiple times or increase
>> the repeat count of the inner loop to trigger the error.  I am not
>> running out of virtual memory, though.  Adding `do (garbage-collect)'
>> to the outer loop does not help either.

> This seems to be a bug caused by inconsistencies in the tree generated
> by a specific dataset.  This recipe triggers the error right away:

This was a simple paren-typo.  Thank you for catching it,

        Stefan

=== modified file 'lisp/emacs-lisp/avl-tree.el'
--- lisp/emacs-lisp/avl-tree.el	2012-01-19 07:21:25 +0000
+++ lisp/emacs-lisp/avl-tree.el	2012-03-27 20:40:27 +0000
@@ -295,9 +295,9 @@
 	        (if (> (* sgn b2) 0) (- sgn) 0)
 	      (avl-tree--node-balance p1)
 	        (if (< (* sgn b2) 0) sgn 0)
-	      (avl-tree--node-branch node branch) p2
-	      (avl-tree--node-balance
-	       (avl-tree--node-branch node branch)) 0))
+                (avl-tree--node-branch node branch) p2))
+      (setf (avl-tree--node-balance
+             (avl-tree--node-branch node branch)) 0)
       nil))))
 
 (defun avl-tree--do-enter (cmpfun root branch data &optional updatefun)