unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Tino Calancha <tino.calancha@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 26961@debbugs.gnu.org, schwab@suse.de, tino.calancha@gmail.com
Subject: bug#26961: 26.0.50; Possible timming issue in regex-tests.el
Date: Fri, 19 May 2017 20:38:40 +0900	[thread overview]
Message-ID: <87shk113gf.fsf@calancha-pc> (raw)
In-Reply-To: <837f1d48uc.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 19 May 2017 10:14:03 +0300")

Eli Zaretskii <eliz@gnu.org> writes:

>> +  AUTO_STRING (inner_format, "`?%c'");
>>    CALLN (Fmessage,
>>           format, file,
>> -         Fmapconcat (Qstring,
>> +         Fmapconcat (list3 (Qlambda, list1 (Qchar),
>> +                            list3 (Qformat, inner_format, Qchar)),
>>                       Fsort (Vlread_unescaped_character_literals, Qlss),
>>                       separator));
>>  }
>> 
>> Do you think this code is wrong?
>
> This does indeed look dangerous: we are in effect consing Lisp data
> structures from stack-based Lisp objects, and then process them in a
> way that could leave some of them lying around when this function
> returns, and its stack becomes invalid.
>
> Can you present the evidence that caused you to suspect this
> particular change?  Were the "unescaped character literals" warning
> displayed during the session which crashed?
Yes, such warning always appear in the crash session.
Loading ‘/home/calancha/soft/emacs-master/test/src/regex-tests.el’: unescaped character literals `?;' detected!
Running 22 tests (2017-05-19 20:24:31+0900)

If i print out the string, when the object is a cons with its car the string
to print, as follows:


--8<-----------------------------cut here---------------start------------->8---
diff --git a/src/alloc.c b/src/alloc.c
index faa14eebb3..20cfb3c88e 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -6664,7 +6664,32 @@ mark_object (Lisp_Object arg)
 	    cdr_count = 0;
 	    goto loop;
 	  }
-	mark_object (ptr->car);
+        po = XPNTR (ptr->car);
+        switch (XTYPE (ptr->car))
+          {
+          case Lisp_String:
+            {
+              if (!STRING_MARKED_P (XSTRING (ptr->car)) &&
+                  !PURE_P (po)                          &&
+                  mem_find (po) == MEM_NIL)
+                {
+                  fprintf (stderr, "[ERROR] mem_find (po) = MEM_NIL, cons %p car %s cdr %p\n",
+                           ptr, XSTRING (ptr->car)->data, XPNTR (ptr->u.cdr));
+                  return;
+                }
+              else
+                {
+                  fprintf (stderr, "[OK] cons %p car %s cdr %p\n",
+                           ptr, XSTRING (ptr->car)->data, XPNTR (ptr->u.cdr));
+                }
+              break;
+            }
+          default:
+            {
+              mark_object (ptr->car);
+            }
+          }
+        mark_object (ptr->car);
 	obj = ptr->u.cdr;
 	cdr_count++;
 	if (cdr_count == mark_object_loop_halt)

--8<-----------------------------cut here---------------end--------------->8---
Then, i see that right before the crash, the string printed out is the name
of the test file containinig the unescaped characters.

[OK] cons 0x2f0a8f0 car /home/calancha/soft/emacs-master/test/src/regex-resources/BOOST.tests cdr 0x2f0a8e0
[ERROR] mem_find (po) = MEM_NIL, cons 0x2f45150 car ‚ cdr 0x2f45140
[OK] cons 0x16d8720 car /home/calancha/soft/emacs-master/test/src/regex-resources/PCRE.tests cdr 0x16d8730
[ERROR] mem_find (po) = MEM_NIL, cons 0x2f45150 car ‚ cdr 0x2f45140
[OK] cons 0x3009910 car /home/calancha/soft/emacs-master/test/src/regex-resources/PTESTS cdr 0x3009900
[ERROR] mem_find (po) = MEM_NIL, cons 0x2f45150 car ‚ cdr 0x2f45140


With:
Fmapconcat (Qstring,
insted of:
Fmapconcat (list3 (Qlambda, list1 (Qchar),
                   list3 (Qformat, inner_format, Qchar)),

we still see the warning, as we should because the test file contains
those chars, but there is _no_ crash.





  reply	other threads:[~2017-05-19 11:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-17 10:19 bug#26961: 26.0.50; Possible timming issue in regex-tests.el Tino Calancha
2017-05-17 13:55 ` Tino Calancha
2017-05-17 16:32   ` Eli Zaretskii
2017-05-18  7:00     ` Tino Calancha
2017-05-18  7:50       ` Andreas Schwab
2017-05-18 15:04       ` Eli Zaretskii
2017-05-19  3:31         ` Tino Calancha
2017-05-19  7:14           ` Eli Zaretskii
2017-05-19 11:38             ` Tino Calancha [this message]
2017-05-20 10:04               ` Eli Zaretskii
2017-05-20 11:20                 ` Tino Calancha
2017-05-20 11:54                   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87shk113gf.fsf@calancha-pc \
    --to=tino.calancha@gmail.com \
    --cc=26961@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=schwab@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).