unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Nicolas Richard <theonewiththeevillook@yahoo.fr>
Cc: 20191-done@debbugs.gnu.org
Subject: bug#20191: 25.0.50; SIGABRT in re_match_2_internal
Date: Fri, 27 Mar 2015 12:37:57 -0700	[thread overview]
Message-ID: <5515B195.2020404@cs.ucla.edu> (raw)
In-Reply-To: <87fv8qwhvd.fsf@yahoo.fr>

[-- Attachment #1: Type: text/plain, Size: 766 bytes --]

On 03/27/2015 09:00 AM, Nicolas Richard wrote:
>
> Should I report either of these as a bug ?

Thanks, don't bother, I fixed it in master with the first attached patch.

> I then get a core dump.

Thanks.  I reproduced that problem.  It's an issue with the Emacs 
debugger, not with regular-expression matching.  (The regular expression 
matcher is very slow with your example -- which is a problem, but I 
suggest filing a separate bug report for the performance problem, as 
this bug report is about a SIGABRT.)

I fixed the problem in master by applying the second and third attached 
patches (which fix some related bugs while I was at it) and am marking 
this as done.  At least, it works for me; if it still doesn't work for 
you we can reopen the bug report.

[-- Attachment #2: 0001-Port-etags-to-DDEBUG.patch --]
[-- Type: text/x-patch, Size: 2800 bytes --]

From 84c7c6fd2b9604fa28e0b834caa46423114b9c5b Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Fri, 27 Mar 2015 11:14:14 -0700
Subject: [PATCH 1/3] Port etags to -DDEBUG

* etags.c (xnew, xrnew) [DEBUG]: Don't include chkmalloc.h, which
is not part of Emacs and is typically not installed.
Instead, just invoke xmalloc and xrealloc as usual.
Problem reported by Nicolas Richard in:
http://bugs.gnu.org/20191#20
(xrnew): Avoid no-longer-needed cast to 'char *'.
(xrealloc): First arg is now void *, not char *.
---
 lib-src/ChangeLog | 11 +++++++++++
 lib-src/etags.c   | 17 ++++-------------
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index 9786809..0bb24c3 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,14 @@
+2015-03-27  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Port etags to -DDEBUG
+	* etags.c (xnew, xrnew) [DEBUG]: Don't include chkmalloc.h, which
+	is not part of Emacs and is typically not installed.
+	Instead, just invoke xmalloc and xrealloc as usual.
+	Problem reported by Nicolas Richard in:
+	http://bugs.gnu.org/20191#20
+	(xrnew): Avoid no-longer-needed cast to 'char *'.
+	(xrealloc): First arg is now void *, not char *.
+
 2015-03-06  Paul Eggert  <eggert@cs.ucla.edu>
 
 	Random minor fixes for movemail
diff --git a/lib-src/etags.c b/lib-src/etags.c
index 7f18755..b1361db 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -176,17 +176,8 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4";
  * SYNOPSIS:	Type *xnew (int n, Type);
  *		void xrnew (OldPointer, int n, Type);
  */
-#if DEBUG
-# include "chkmalloc.h"
-# define xnew(n,Type)	  ((Type *) trace_malloc (__FILE__, __LINE__, \
-						  (n) * sizeof (Type)))
-# define xrnew(op,n,Type) ((op) = (Type *) trace_realloc (__FILE__, __LINE__, \
-					(char *) (op), (n) * sizeof (Type)))
-#else
-# define xnew(n,Type)	  ((Type *) xmalloc ((n) * sizeof (Type)))
-# define xrnew(op,n,Type) ((op) = (Type *) xrealloc ( \
-					(char *) (op), (n) * sizeof (Type)))
-#endif
+#define xnew(n, Type)      ((Type *) xmalloc ((n) * sizeof (Type)))
+#define xrnew(op, n, Type) ((op) = (Type *) xrealloc (op, (n) * sizeof (Type)))
 
 typedef void Lang_function (FILE *);
 
@@ -348,7 +339,7 @@ static void canonicalize_filename (char *);
 static void linebuffer_init (linebuffer *);
 static void linebuffer_setlen (linebuffer *, int);
 static void *xmalloc (size_t);
-static void *xrealloc (char *, size_t);
+static void *xrealloc (void *, size_t);
 
 \f
 static char searchar = '/';	/* use /.../ searches */
@@ -6533,7 +6524,7 @@ xmalloc (size_t size)
 }
 
 static void *
-xrealloc (char *ptr, size_t size)
+xrealloc (void *ptr, size_t size)
 {
   void *result = realloc (ptr, size);
   if (result == NULL)
-- 
2.1.0


[-- Attachment #3: 0002-Port-user-login-name-initialization-to-Qnil-0.patch --]
[-- Type: text/x-patch, Size: 2327 bytes --]

From 589a4034b7af522c5b8107d5089fb1aec523a1e4 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Fri, 27 Mar 2015 11:57:44 -0700
Subject: [PATCH 2/3] Port user-login-name initialization to Qnil == 0

* editfns.c (Fuser_login_name, Fuser_real_login_name)
(syms_of_editfns): Don't rely on all-bits-zero being an Elisp integer,
as this is no longer true now that Qnil == 0.
---
 src/ChangeLog | 5 +++++
 src/editfns.c | 5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 3f9ab4f..61f2a84 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
 2015-03-27  Paul Eggert  <eggert@cs.ucla.edu>
 
+	Port user-login-name initialization to Qnil == 0
+	* editfns.c (Fuser_login_name, Fuser_real_login_name)
+	(syms_of_editfns): Don't rely on all-bits-zero being an Elisp integer,
+	as this is no longer true now that Qnil == 0.
+
 	Assume !BROKEN_NON_BLOCKING_CONNECT
 	From a suggestion by Eli Zaretskii in:
 	http://lists.gnu.org/archive/html/emacs-devel/2015-03/msg00824.html
diff --git a/src/editfns.c b/src/editfns.c
index f463890..7d3e462 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1191,7 +1191,7 @@ of the user with that uid, or nil if there is no such user.  */)
   /* Set up the user name info if we didn't do it before.
      (That can happen if Emacs is dumpable
      but you decide to run `temacs -l loadup' and not dump.  */
-  if (INTEGERP (Vuser_login_name))
+  if (NILP (Vuser_login_name))
     init_editfns ();
 
   if (NILP (uid))
@@ -1214,7 +1214,7 @@ This ignores the environment variables LOGNAME and USER, so it differs from
   /* Set up the user name info if we didn't do it before.
      (That can happen if Emacs is dumpable
      but you decide to run `temacs -l loadup' and not dump.  */
-  if (INTEGERP (Vuser_login_name))
+  if (NILP (Vuser_login_name))
     init_editfns ();
   return Vuser_real_login_name;
 }
@@ -4955,6 +4955,7 @@ functions if all the text being accessed has this property.  */);
 
   DEFVAR_LISP ("user-login-name", Vuser_login_name,
 	       doc: /* The user's name, taken from environment variables if possible.  */);
+  Vuser_login_name = Qnil;
 
   DEFVAR_LISP ("user-real-login-name", Vuser_real_login_name,
 	       doc: /* The user's name, based upon the real uid only.  */);
-- 
2.1.0


[-- Attachment #4: 0003-Avoid-some-core-dumps-in-X-session-management.patch --]
[-- Type: text/x-patch, Size: 5960 bytes --]

From 01d1024bec7781066440104ebee0b186382e10f3 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Fri, 27 Mar 2015 12:10:44 -0700
Subject: [PATCH 3/3] Avoid some core dumps in X session management

Derived from a bug report by Nicolas Richard in:
http://bugs.gnu.org/20191#20
* xsmfns.c (smc_save_yourself_CB): Don't dump core if
invocation-name is not a string.  Initialize user-login-name if it
is not already initialized, and don't dump core if it is not a
string.
(create_client_leader_window): Don't dump core if x-resource-name
and x-resource-class are not both strings.
(x_session_initialize): Don't dump core if x-session-previous-id,
invocation-directory, and invocation-name are not strings.
---
 src/ChangeLog | 14 ++++++++++++++
 src/xsmfns.c  | 57 +++++++++++++++++++++++++++++++++------------------------
 2 files changed, 47 insertions(+), 24 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 61f2a84..db3056c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,6 +1,20 @@
 2015-03-27  Paul Eggert  <eggert@cs.ucla.edu>
 
+	Avoid some core dumps in X session management
+	Derived from a bug report by Nicolas Richard in:
+	http://bugs.gnu.org/20191#20
+	* xsmfns.c (smc_save_yourself_CB): Don't dump core if
+	invocation-name is not a string.  Initialize user-login-name if it
+	is not already initialized, and don't dump core if it is not a
+	string.
+	(create_client_leader_window): Don't dump core if x-resource-name
+	and x-resource-class are not both strings.
+	(x_session_initialize): Don't dump core if x-session-previous-id,
+	invocation-directory, and invocation-name are not strings.
+
 	Port user-login-name initialization to Qnil == 0
+	Derived from a bug report by Nicolas Richard in:
+	http://bugs.gnu.org/20191#20
 	* editfns.c (Fuser_login_name, Fuser_real_login_name)
 	(syms_of_editfns): Don't rely on all-bits-zero being an Elisp integer,
 	as this is no longer true now that Qnil == 0.
diff --git a/src/xsmfns.c b/src/xsmfns.c
index 0e635d3..375b51c 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -168,7 +168,6 @@ smc_save_yourself_CB (SmcConn smcConn,
   int val_idx = 0, vp_idx = 0;
   int props_idx = 0;
   int i;
-  char *cwd = get_current_dir_name ();
   char *smid_opt, *chdir_opt = NULL;
 
   /* How to start a new instance of Emacs.  */
@@ -181,27 +180,34 @@ smc_save_yourself_CB (SmcConn smcConn,
   props[props_idx]->vals[0].value = emacs_program;
   ++props_idx;
 
-  /* The name of the program.  */
-  props[props_idx] = &prop_ptr[props_idx];
-  props[props_idx]->name = xstrdup (SmProgram);
-  props[props_idx]->type = xstrdup (SmARRAY8);
-  props[props_idx]->num_vals = 1;
-  props[props_idx]->vals = &values[val_idx++];
-  props[props_idx]->vals[0].length = SBYTES (Vinvocation_name);
-  props[props_idx]->vals[0].value = SDATA (Vinvocation_name);
-  ++props_idx;
+  if (STRINGP (Vinvocation_name))
+    {
+      /* The name of the program.  */
+      props[props_idx] = &prop_ptr[props_idx];
+      props[props_idx]->name = xstrdup (SmProgram);
+      props[props_idx]->type = xstrdup (SmARRAY8);
+      props[props_idx]->num_vals = 1;
+      props[props_idx]->vals = &values[val_idx++];
+      props[props_idx]->vals[0].length = SBYTES (Vinvocation_name);
+      props[props_idx]->vals[0].value = SDATA (Vinvocation_name);
+      ++props_idx;
+    }
 
   /* User id.  */
-  props[props_idx] = &prop_ptr[props_idx];
-  props[props_idx]->name = xstrdup (SmUserID);
-  props[props_idx]->type = xstrdup (SmARRAY8);
-  props[props_idx]->num_vals = 1;
-  props[props_idx]->vals = &values[val_idx++];
-  props[props_idx]->vals[0].length = SBYTES (Vuser_login_name);
-  props[props_idx]->vals[0].value = SDATA (Vuser_login_name);
-  ++props_idx;
-
+  Lisp_Object user_login_name = Fuser_login_name (Qnil);
+  if (STRINGP (user_login_name))
+    {
+      props[props_idx] = &prop_ptr[props_idx];
+      props[props_idx]->name = xstrdup (SmUserID);
+      props[props_idx]->type = xstrdup (SmARRAY8);
+      props[props_idx]->num_vals = 1;
+      props[props_idx]->vals = &values[val_idx++];
+      props[props_idx]->vals[0].length = SBYTES (user_login_name);
+      props[props_idx]->vals[0].value = SDATA (user_login_name);
+      ++props_idx;
+    }
 
+  char *cwd = get_current_dir_name ();
   if (cwd)
     {
       props[props_idx] = &prop_ptr[props_idx];
@@ -372,6 +378,7 @@ create_client_leader_window (struct x_display_info *dpyinfo, char *client_ID)
                            -1, -1, 1, 1,
                            CopyFromParent, CopyFromParent, CopyFromParent);
 
+  validate_x_resource_name ();
   class_hints.res_name = SSDATA (Vx_resource_name);
   class_hints.res_class = SSDATA (Vx_resource_class);
   XSetClassHint (dpyinfo->display, w, &class_hints);
@@ -402,22 +409,24 @@ x_session_initialize (struct x_display_info *dpyinfo)
 
   /* Check if we where started by the session manager.  If so, we will
      have a previous id.  */
-  if (! NILP (Vx_session_previous_id) && STRINGP (Vx_session_previous_id))
+  if (STRINGP (Vx_session_previous_id))
     previous_id = SSDATA (Vx_session_previous_id);
 
   /* Construct the path to the Emacs program.  */
-  if (! NILP (Vinvocation_directory))
+  if (STRINGP (Vinvocation_directory))
     name_len += SBYTES (Vinvocation_directory);
-  name_len += SBYTES (Vinvocation_name);
+  if (STRINGP (Vinvocation_name))
+    name_len += SBYTES (Vinvocation_name);
 
   /* This malloc will not be freed, but it is only done once, and hopefully
      not very large   */
   emacs_program = xmalloc (name_len + 1);
   char *z = emacs_program;
 
-  if (! NILP (Vinvocation_directory))
+  if (STRINGP (Vinvocation_directory))
     z = lispstpcpy (z, Vinvocation_directory);
-  lispstpcpy (z, Vinvocation_name);
+  if (STRINGP (Vinvocation_name))
+    lispstpcpy (z, Vinvocation_name);
 
   /* The SM protocol says all callbacks are mandatory, so set up all
      here and in the mask passed to SmcOpenConnection.  */
-- 
2.1.0


  reply	other threads:[~2015-03-27 19:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-24 15:14 bug#20191: 25.0.50; SIGABRT in re_match_2_internal Nicolas Richard
     [not found] ` <handler.20191.B.142721003329390.ack@debbugs.gnu.org>
2015-03-24 16:22   ` bug#20191: Acknowledgement (25.0.50; SIGABRT in re_match_2_internal) Nicolas Richard
2015-03-24 17:25 ` bug#20191: 25.0.50; SIGABRT in re_match_2_internal Paul Eggert
2015-03-25  6:45   ` Nicolas Richard
2015-03-26 17:49     ` Paul Eggert
2015-03-27 16:00       ` Nicolas Richard
2015-03-27 19:37         ` Paul Eggert [this message]
2015-03-28  8:38           ` Nicolas Richard

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=5515B195.2020404@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=20191-done@debbugs.gnu.org \
    --cc=theonewiththeevillook@yahoo.fr \
    /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).