Subject: Re: bug#18438: 24.4.50; assertion failed in bidi.c

From: Eli Zaretskii <[email-masked]>
Date: Tue, 30 Sep 2014 18:24:15 +0300

> Date: Tue, 30 Sep 2014 11:28:35 +1300
> From: [email-masked]
> Cc: Eli Zaretskii <[email-masked]>, Ken Brown <[email-masked]>
> 
> On Mon, 29 Sep 2014 20:00:16 +0300, Eli Zaretskii wrote:
> >
> > Let's start by replacing eassert with its equivalent.  Please run 
> > with
> > the change below for some time and see if the assertions still 
> > happen.
> >
> > (The purpose is to see whether small changes in the code have drastic
> > effects on the problem.  If they do, it will be hard to know whether
> > some more serious change solves the problem or simply hides it.)
> 
> Yes, they're still happening; I just got one after running with the 
> patch for only a few hours.

OK, so far so good.  How about the one below (which tries to reveal
the face of the beast)?

=== modified file 'src/bidi.c'
--- src/bidi.c	2014-04-06 15:56:01 +0000
+++ src/bidi.c	2014-09-30 15:21:28 +0000
@@ -326,7 +326,12 @@ bidi_get_type (int ch, bidi_dir_t overri
 static void
 bidi_check_type (bidi_type_t type)
 {
-  eassert (UNKNOWN_BT <= type && type <= NEUTRAL_ON);
+  if (!(suppress_checking || (UNKNOWN_BT <= type && type <= NEUTRAL_ON)))
+    {
+      fprintf (stderr, "\r\n%s:%d: bidi type %d is not in [%d..%d]\r\n",
+	       __FILE__, __LINE__, type, UNKNOWN_BT, NEUTRAL_ON);
+      emacs_abort ();
+    }
 }
 
 /* Given a bidi TYPE of a character, return its category.  */