From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#11519: "Wrong type argument: characterp" building custom-deps while boostrapping Date: Tue, 22 May 2012 22:00:46 +0300 Message-ID: <83k404xcpt.fsf@gnu.org> References: <83d360yw48.fsf@gnu.org> <834nrazrtl.fsf@gnu.org> <831umez1p7.fsf@gnu.org> <83vcjpxw18.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE X-Trace: dough.gmane.org 1337713294 19612 80.91.229.3 (22 May 2012 19:01:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 22 May 2012 19:01:34 +0000 (UTC) Cc: lekktu@gmail.com, schwab@linux-m68k.org, 11519@debbugs.gnu.org To: Stefan Monnier , Kenichi Handa Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue May 22 21:01:31 2012 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 1SWuKl-0007Dz-HF for geb-bug-gnu-emacs@m.gmane.org; Tue, 22 May 2012 21:01:27 +0200 Original-Received: from localhost ([::1]:53849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWuKk-0006pw-VS for geb-bug-gnu-emacs@m.gmane.org; Tue, 22 May 2012 15:01:26 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:44769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWuKh-0006pW-9A for bug-gnu-emacs@gnu.org; Tue, 22 May 2012 15:01:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SWuKb-0007Vl-NU for bug-gnu-emacs@gnu.org; Tue, 22 May 2012 15:01:22 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57967) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWuKb-0007Ve-Jx for bug-gnu-emacs@gnu.org; Tue, 22 May 2012 15:01:17 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SWuLK-0000oS-2m for bug-gnu-emacs@gnu.org; Tue, 22 May 2012 15:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 22 May 2012 19:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11519 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11519-submit@debbugs.gnu.org id=B11519.13377133133108 (code B ref 11519); Tue, 22 May 2012 19:02:02 +0000 Original-Received: (at 11519) by debbugs.gnu.org; 22 May 2012 19:01:53 +0000 Original-Received: from localhost ([127.0.0.1]:39280 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SWuLA-0000o4-GA for submit@debbugs.gnu.org; Tue, 22 May 2012 15:01:53 -0400 Original-Received: from mtaout23.012.net.il ([80.179.55.175]:61655) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SWuL7-0000nr-KI for 11519@debbugs.gnu.org; Tue, 22 May 2012 15:01:51 -0400 Original-Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0M4F00300U4IWF00@a-mtaout23.012.net.il> for 11519@debbugs.gnu.org; Tue, 22 May 2012 22:00:36 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.210.75]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0M4F003T2U4ZW700@a-mtaout23.012.net.il>; Tue, 22 May 2012 22:00:36 +0300 (IDT) In-reply-to: X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:60285 Archived-At: > From: Stefan Monnier > Cc: Andreas Schwab , lekktu@gmail.com, 115= 19@debbugs.gnu.org > Date: Mon, 21 May 2012 16:39:56 -0400 >=20 > I suggest you let-bind some witness variable is re_search_2 and the= n in > the buffer-relocation code, you test this var and abort if it's non= -nil. > That should let us catch the offender red-handed, after which we wi= ll > know better how to fix the problem. I did the equivalent of the above, but without changing the source (t= o minimize the chances that the bug will disappear). Is the evidence below conclusive enough? Breakpoint 3, search_buffer (string=3D272417249, pos=3D1, pos_byte= =3D1, lim=3D48448, lim_byte=3D51025, n=3D1, RE=3D1, trt=3D61843973, inverse_trt= =3D61841925, posix=3D0) at search.c:1206 1206 val =3D re_search_2 (bufp, (char *) p1, s1, (char= *) p2, s2, $1771 =3D 272417249 $1772 =3D (struct Lisp_String *) 0x103cc1e0 "(provide[ =09\n]+\\('\\|(quote[ =09\n]\\)[ =09\n]*ethio-util[ = =09\n)]" (gdb) p current_buffer->text->beg $1773 =3D ( unsigned char *) 0x10757948 ";;; ethio-util.el --- utilities fo= r Ethiopic -*- coding: utf-8-emacs; -*-\n\n;; Copyright (C) 1997-1998= , 2002-2012 Free Software Foundation, Inc.\n;; Copyright (C) 1997, 1= 998, 1999, 2000, 2001, 2002, 20"... (gdb) p *p1@20 $1774 =3D ";;; ethio-util.el --" (gdb) p p1 $1775 =3D ( unsigned char *) 0x10757948 ";;; ethio-util.el --- utilities fo= r Ethiopic -*- coding: utf-8-emacs; -*-\n\n;; Copyright (C) 1997-1998= , 2002-2012 Free Software Foundation, Inc.\n;; Copyright (C) 1997, 1= 998, 1999, 2000, 2001, 2002, 20"... So at this point, before we call re_search_2, p1 and current_buffer->text->beg point to the same memory. Now: (gdb) watch current_buffer->text->beg Hardware watchpoint 4: current_buffer->text->beg (gdb) c Continuing. Hardware watchpoint 4: current_buffer->text->beg Old value =3D (unsigned char *) 0x10757948 ";;; ethio-util.el --- utilities f= or Ethiopic -*- coding: utf-8-emacs; -*-\n\n;; Copyright (C) 1997-1998, 2002-20= 12 Free Soft ware Foundation, Inc.\n;; Copyright (C) 1997, 1998, 1999, 2000, 200= 1, 2002, 20". .. New value =3D (unsigned char *) 0x10826948 ";;; ethio-util.el --- utilities f= or Ethiopic -*- coding: utf-8-emacs; -*-\n\n;; Copyright (C) 1997-1998, 2002-20= 12 Free Soft ware Foundation, Inc.\n;; Copyright (C) 1997, 1998, 1999, 2000, 200= 1, 2002, 20"... r_alloc_sbrk (size=3D847872) at ralloc.c:808 808 for (b =3D last_bloc; b !=3D NIL_BLOC; b =3D b->p= rev) Note that the address of buffer text has changed from 0x10757948 to 0x10826948. And the culprit is ... (gdb) bt #0 r_alloc_sbrk (size=3D847872) at ralloc.c:808 #1 0x012e9dc0 in get_contiguous_space (size=3D847872, position= =3D0x10748000) at gmalloc.c:447 #2 0x012ea662 in _malloc_internal_nolock (size=3D786436) at gmallo= c.c:821 #3 0x012eaa4c in _malloc_internal (size=3D786436) at gmalloc.c:904 #4 0x012eaa99 in e_malloc (size=3D786436) at gmalloc.c:927 #5 0x0103a3b2 in emacs_blocked_malloc (size=3D786436, ptr=3D0x0) a= t alloc.c:1308 #6 0x012eaa99 in e_malloc (size=3D786436) at gmalloc.c:927 #7 0x010397fb in xmalloc (size=3D786436) at alloc.c:727 #8 0x0120da2d in load_charset_map_from_file (charset=3D0x1944970, mapfile=3D57455953, control_flag=3D1) at charset.c:501 #9 0x0120e480 in load_charset (charset=3D0x1944970, control_flag= =3D1) at charset.c:646 #10 0x01214cc9 in maybe_unify_char (c=3D1704385, val=3D57027682) at= charset.c:1644 #11 0x0128b4a0 in string_char ( p=3D0x1075d630 " 2.=C3=B7=C3=A1=D7=97=D7=92 3.=C3=B7=C3=A1= =D7=97=D7=93 4.=C3=B7=C3=A1=D7=97=D7=94 5.=C3=B7=C3=A1=D7=97\200\")= \n (cond\n ((=3D arg ?1)\n (insert \"=C3=B7=C3=A1=D7=97\201\"))= \n ((=3D arg ?2)\n (insert \"=C3=B7=C3=A1=D7=97=D7=92\"))\n ((= =3D arg ?3)\n (insert \"=C3=B7=C3=A1=D7=97=D7=93\"))\n ((=3D arg= ?4)\n (insert \"=C3=B7=C3=A1=D7=97=D7=94\"))\n ((=3D arg ?5"...= , advanced=3D0x0, len=3D0x82dcec) at character.c:200 #12 0x01142f65 in re_search_2 (bufp=3D0x1933c08, str1=3D0x10757948 ";;; ethio-util.el --- utilities for Ethiopic= -*- coding: utf-8-emacs; -*-\n\n;; Copyright (C) 1997-1998, 20= 02-2012 Free Software Foundation, Inc.\n;; Copyright (C) 1997, 1998,= 1999, 2000, 2001, 2002, 20"..., size1=3D51024, str2=3D0x1077fb17 "", size2=3D0, startpos=3D2374= 9, range=3D27244, regs=3D0x19351f8, stop=3D51024) at regex.c:4421 #13 0x010fbd78 in search_buffer (string=3D272417249, pos=3D1, pos_b= yte=3D1, lim=3D48448, lim_byte=3D51025, n=3D1, RE=3D1, trt=3D61843973, i= nverse_trt=3D61841925, posix=3D0) at search.c:1207 #14 0x010fb578 in search_command (string=3D272417249, bound=3D56838= 170, noerror=3D56838194, count=3D56838170, direction=3D1, RE=3D1, po= six=3D0) at search.c:997 #15 0x010fefa4 in Fre_search_forward (regexp=3D272417249, bound= =3D56838170, noerror=3D56838194, count=3D56838170) at search.c:2165 The fragment of regex.c that triggers this is as follows: =09 if (RE_TRANSLATE_P (translate)) =09=09{ =09=09 if (multibyte) =09=09 while (range > lim) =09=09 { =09=09=09int buf_charlen; >>>>>>>>>>>>>>>>>=09buf_ch =3D STRING_CHAR_AND_LENGTH (d, buf_cha= rlen); =09=09=09buf_ch =3D RE_TRANSLATE (translate, buf_ch); =09=09=09if (fastmap[CHAR_LEADING_CODE (buf_ch)]) =09=09=09 break; =09=09=09range -=3D buf_charlen; =09=09=09d +=3D buf_charlen; =09=09 } The marked line calls string_char, which calls maybe_unify_char, whic= h calls load_charset, which causes memory allocation and relocation of buffer text. The very next call to RE_TRANSLATE, which calls char_table_translate, throws an error because buf_ch is garbage. If you agree with the diagnosis, then how about the change below? It fixes the problem for me. (Or is there a better way?) If accepted, = I will add the necessary commentary to this code and a prototype for th= e new function. In any case, I suggest to install the fix on the emacs-24 branch, because this issue is a disaster waiting to happen. =3D=3D=3D modified file 'src/ralloc.c' --- src/ralloc.c=092012-04-16 01:18:13 +0000 +++ src/ralloc.c=092012-05-22 18:39:25 +0000 @@ -1143,6 +1143,12 @@ r_alloc_reset_variable (POINTER *old, PO bloc->variable =3D new; } =20 +void +r_alloc_inhibit_buffer_relocation (int inhibit) +{ + use_relocatable_buffers =3D (inhibit ? 0 : 1); +} + =0C /*******************************************************************= **** =09=09=09 Initialization =3D=3D=3D modified file 'src/search.c' --- src/search.c=092012-05-17 00:03:49 +0000 +++ src/search.c=092012-05-22 18:41:23 +0000 @@ -1158,12 +1158,19 @@ search_buffer (Lisp_Object string, EMACS while (n < 0) =09{ =09 EMACS_INT val; + +#ifdef REL_ALLOC +=09 r_alloc_inhibit_buffer_relocation (1); +#endif =09 val =3D re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2, =09=09=09 pos_byte - BEGV_BYTE, lim_byte - pos_byte, =09=09=09 (NILP (Vinhibit_changing_match_data) =09=09=09 ? &search_regs : &search_regs_1), =09=09=09 /* Don't allow match past current point */ =09=09=09 pos_byte - BEGV_BYTE); +#ifdef REL_ALLOC +=09 r_alloc_inhibit_buffer_relocation (0); +#endif =09 if (val =3D=3D -2) =09 { =09 matcher_overflow (); @@ -1202,11 +1209,18 @@ search_buffer (Lisp_Object string, EMACS while (n > 0) =09{ =09 EMACS_INT val; + +#ifdef REL_ALLOC +=09 r_alloc_inhibit_buffer_relocation (1); +#endif =09 val =3D re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2, =09=09=09 pos_byte - BEGV_BYTE, lim_byte - pos_byte, =09=09=09 (NILP (Vinhibit_changing_match_data) =09=09=09 ? &search_regs : &search_regs_1), =09=09=09 lim_byte - BEGV_BYTE); +#ifdef REL_ALLOC +=09 r_alloc_inhibit_buffer_relocation (0); +#endif =09 if (val =3D=3D -2) =09 { =09 matcher_overflow ();