From: Paul Eggert <eggert@cs.ucla.edu>
To: Eli Zaretskii <eliz@gnu.org>, Jim Meyering <jim@meyering.net>
Cc: emacs-devel@gnu.org
Subject: Re: building/using address-sanitizer-enabled emacs?
Date: Tue, 16 May 2017 14:49:46 -0700 [thread overview]
Message-ID: <b2ab234a-6b8e-0706-a3a9-e901cd0d937c@cs.ucla.edu> (raw)
In-Reply-To: <83bmr1bfhj.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 860 bytes --]
On 05/09/2017 07:41 PM, Eli Zaretskii wrote:
>> From: Jim Meyering<jim@meyering.net>
>> With the above, I thought I was avoiding the undumping issue by using temacs.
> Indeed, I believe the problem you reported is unrelated to unexec.
You're right, I didn't read Jim's message carefully enough. I see that
the AddressSanitizer code suffered some bitrot since I last got it
working; among other things its output was being discarded on Fedora 25
x86-64, which at first gave me a false sense of security.... I installed
the attached patches to work around the GCC problem that Jim reported,
the improper output discard, and one minor memory leak uncovered by
AddressSanitizer. When I run Emacs with AddressSanitizer now, it
reports some other minor memory leaks, almost all from the fontconfig
library. I do not observe any problems with SAFE_ALLOCA.
[-- Attachment #2: 0001-Simplify-procname-code-to-avoid-GCC-bug.patch --]
[-- Type: text/x-patch, Size: 3918 bytes --]
From be9e60fc3c43cc49cc5d749924c3e96737ae297c Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 16 May 2017 14:29:18 -0700
Subject: [PATCH 1/3] Simplify procname code to avoid GCC bug
* src/process.c (server_accept_connection): Simplify and avoid
multiple calls and struct literals in the last case of a switch.
The old code ran afoul of GCC bug 80659, which caused an internal
compiler error. Problem reported by Jim Meyering in:
http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00182.html
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80659
---
src/process.c | 53 ++++++++++++++++++++++++-----------------------------
1 file changed, 24 insertions(+), 29 deletions(-)
diff --git a/src/process.c b/src/process.c
index 4a28639..fdea977 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4659,7 +4659,7 @@ static EMACS_INT connect_counter = 0;
static void
server_accept_connection (Lisp_Object server, int channel)
{
- Lisp_Object proc, caller, name, buffer;
+ Lisp_Object buffer;
Lisp_Object contact, host, service;
struct Lisp_Process *ps = XPROCESS (server);
struct Lisp_Process *p;
@@ -4701,49 +4701,43 @@ server_accept_connection (Lisp_Object server, int channel)
information for this process. */
host = Qt;
service = Qnil;
+ Lisp_Object args[11];
+ int nargs = 0;
+ AUTO_STRING (procname_format_in, "%s <%d.%d.%d.%d:%d>");
+ AUTO_STRING (procname_format_in6, "%s <[%x:%x:%x:%x:%x:%x:%x:%x]:%d>");
+ AUTO_STRING (procname_format_default, "%s <%d>");
switch (saddr.sa.sa_family)
{
case AF_INET:
{
+ args[nargs++] = procname_format_in;
+ nargs++;
unsigned char *ip = (unsigned char *)&saddr.in.sin_addr.s_addr;
-
- AUTO_STRING (ipv4_format, "%d.%d.%d.%d");
- host = CALLN (Fformat, ipv4_format,
- make_number (ip[0]), make_number (ip[1]),
- make_number (ip[2]), make_number (ip[3]));
service = make_number (ntohs (saddr.in.sin_port));
- AUTO_STRING (caller_format, " <%s:%d>");
- caller = CALLN (Fformat, caller_format, host, service);
+ for (int i = 0; i < 4; i++)
+ args[nargs++] = make_number (ip[i]);
+ args[nargs++] = service;
}
break;
#ifdef AF_INET6
case AF_INET6:
{
- Lisp_Object args[9];
+ args[nargs++] = procname_format_in6;
+ nargs++;
uint16_t *ip6 = (uint16_t *)&saddr.in6.sin6_addr;
- int i;
-
- AUTO_STRING (ipv6_format, "%x:%x:%x:%x:%x:%x:%x:%x");
- args[0] = ipv6_format;
- for (i = 0; i < 8; i++)
- args[i + 1] = make_number (ntohs (ip6[i]));
- host = CALLMANY (Fformat, args);
service = make_number (ntohs (saddr.in.sin_port));
- AUTO_STRING (caller_format, " <[%s]:%d>");
- caller = CALLN (Fformat, caller_format, host, service);
+ for (int i = 0; i < 8; i++)
+ args[nargs++] = make_number (ip6[i]);
+ args[nargs++] = service;
}
break;
#endif
-#ifdef HAVE_LOCAL_SOCKETS
- case AF_LOCAL:
-#endif
default:
- caller = Fnumber_to_string (make_number (connect_counter));
- AUTO_STRING (space_less_than, " <");
- AUTO_STRING (greater_than, ">");
- caller = concat3 (space_less_than, caller, greater_than);
+ args[nargs++] = procname_format_default;
+ nargs++;
+ args[nargs++] = make_number (connect_counter);
break;
}
@@ -4764,16 +4758,17 @@ server_accept_connection (Lisp_Object server, int channel)
buffer = ps->name;
if (!NILP (buffer))
{
- buffer = concat2 (buffer, caller);
- buffer = Fget_buffer_create (buffer);
+ args[1] = buffer;
+ buffer = Fget_buffer_create (Fformat (nargs, args));
}
}
/* Generate a unique name for the new server process. Combine the
server process name with the caller identification. */
- name = concat2 (ps->name, caller);
- proc = make_process (name);
+ args[1] = ps->name;
+ Lisp_Object name = Fformat (nargs, args);
+ Lisp_Object proc = make_process (name);
chan_process[s] = proc;
--
2.9.4
[-- Attachment #3: 0002-Do-not-discard-AddressSanitizer-stderr.patch --]
[-- Type: text/x-patch, Size: 887 bytes --]
From 69d0a8500cabc4c034e2d6d873af54a8e8362e3b Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 16 May 2017 14:30:37 -0700
Subject: [PATCH 2/3] Do not discard AddressSanitizer stderr
* src/emacs.c (close_output_streams) [ADDRESS_SANITIZER]:
Do not close stderr.
---
src/emacs.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/emacs.c b/src/emacs.c
index 9339d60..3aa914f 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -657,8 +657,11 @@ close_output_streams (void)
_exit (EXIT_FAILURE);
}
- if (close_stream (stderr) != 0)
- _exit (EXIT_FAILURE);
+ /* Do not close stderr if addresses are being sanitized, as the
+ sanitizer might report to stderr after this function is
+ invoked. */
+ if (!ADDRESS_SANITIZER && close_stream (stderr) != 0)
+ _exit (EXIT_FAILURE);
}
/* ARGSUSED */
--
2.9.4
[-- Attachment #4: 0003-Fix-minor-timezone-memory-leak.patch --]
[-- Type: text/x-patch, Size: 1216 bytes --]
From f7c07930b581b1bcfdfb1874b6883233516bdf11 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 16 May 2017 14:19:36 -0700
Subject: [PATCH 3/3] Fix minor timezone memory leak
* src/editfns.c (wall_clock_tz): Remove; unused.
---
src/editfns.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/src/editfns.c b/src/editfns.c
index ecb8e3f..75eb75a 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -81,10 +81,8 @@ static Lisp_Object styled_format (ptrdiff_t, Lisp_Object *, bool);
enum { tzeqlen = sizeof "TZ=" - 1 };
-/* Time zones equivalent to current local time, to wall clock time,
- and to UTC, respectively. */
+/* Time zones equivalent to current local time and to UTC, respectively. */
static timezone_t local_tz;
-static timezone_t wall_clock_tz;
static timezone_t const utc_tz = 0;
/* The cached value of Vsystem_name. This is used only to compare it
@@ -269,7 +267,6 @@ init_editfns (bool dumping)
/* Set the time zone rule now, so that the call to putenv is done
before multiple threads are active. */
- wall_clock_tz = xtzalloc (0);
tzlookup (tz ? build_string (tz) : Qwall, true);
pw = getpwuid (getuid ());
--
2.9.4
next prev parent reply other threads:[~2017-05-16 21:49 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-07 3:40 building/using address-sanitizer-enabled emacs? Jim Meyering
2017-05-07 19:54 ` Paul Eggert
2017-05-07 21:44 ` Jim Meyering
2017-05-08 2:36 ` Eli Zaretskii
2017-05-08 5:42 ` Paul Eggert
2017-05-08 14:39 ` Eli Zaretskii
2017-05-08 14:46 ` Paul Eggert
2017-05-08 16:04 ` Eli Zaretskii
2017-05-09 5:48 ` Jim Meyering
2017-05-09 15:18 ` Eli Zaretskii
2017-05-09 17:06 ` Jim Meyering
2017-05-09 17:45 ` Eli Zaretskii
2017-05-09 19:22 ` Paul Eggert
2017-05-09 22:49 ` Jim Meyering
2017-05-10 2:41 ` Eli Zaretskii
2017-05-16 21:49 ` Paul Eggert [this message]
2017-05-17 2:24 ` Eli Zaretskii
2017-05-17 14:46 ` Paul Eggert
2017-05-17 16:06 ` Eli Zaretskii
2017-05-17 20:05 ` Paul Eggert
2017-05-18 4:15 ` Eli Zaretskii
2017-05-09 23:15 ` Philipp Stephani
2017-05-10 2:42 ` Eli Zaretskii
2017-05-10 22:24 ` Philipp Stephani
2017-05-13 8:02 ` Eli Zaretskii
2017-05-13 15:08 ` [PATCH] Fix use of sockaddr_in Philipp Stephani
2017-05-13 16:52 ` Eli Zaretskii
2017-05-13 19:14 ` Andreas Schwab
2017-05-13 19:29 ` Eli Zaretskii
2017-05-13 20:05 ` Andreas Schwab
2017-05-14 2:32 ` Eli Zaretskii
2017-05-14 6:11 ` Andreas Schwab
2017-05-14 14:20 ` Eli Zaretskii
2017-05-15 6:15 ` Paul Eggert
2017-05-15 9:04 ` Philipp Stephani
2017-05-17 20:38 ` Paul Eggert
2017-05-27 11:35 ` Philipp Stephani
2017-05-17 15:16 ` Eli Zaretskii
2017-05-17 20:15 ` Paul Eggert
2017-05-14 10:28 ` Lars Ingebrigtsen
2017-05-14 19:06 ` Philipp Stephani
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=b2ab234a-6b8e-0706-a3a9-e901cd0d937c@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=jim@meyering.net \
/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).