GNU bug report logs - #38632
27.0.50; Emacs process name is changed permanently upon creating a named thread

Previous Next

Package: emacs;

Reported by: Ihor Radchenko <yantar92 <at> gmail.com>

Date: Mon, 16 Dec 2019 06:45:02 UTC

Severity: normal

Merged with 39003

Found in versions 27.0.50, 27.0.60

Fixed in version 27.1

Done: Mattias Engdegård <mattiase <at> acm.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 38632 in the body.
You can then email your comments to 38632 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Mon, 16 Dec 2019 06:45:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ihor Radchenko <yantar92 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 16 Dec 2019 06:45:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.50; Emacs process name is changed permanently upon creating a
 named thread
Date: Mon, 16 Dec 2019 14:42:38 +0800
Observed behaviour:

When I try to create a named thread like

(make-thread (lambda () (+ 1 2)) "test-emacs-async")

the emacs process gets renamed to "test-emacs-async" even after the
thread returns. Making another thread with different name renames emacs
process again.

Expected behaviour:

Emacs process name remains unchanged.

Note: by process name, I mean "COMMAND" field in top output. 

Best,
Ihor


In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0)
 of 2019-12-16 built on yantar92-laptop
Repository revision: 7254b6346229a7b71b69f71e2d8eee113f02585a
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12005000
System Description: Gentoo/Linux




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Tue, 17 Dec 2019 20:07:02 GMT) Full text and rfc822 format available.

Message #8 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ihor Radchenko <yantar92 <at> gmail.com>
Cc: 38632 <at> debbugs.gnu.org
Subject: Re: bug#38632: 27.0.50;
 Emacs process name is changed permanently upon creating a named thread
Date: Tue, 17 Dec 2019 22:05:52 +0200
> From: Ihor Radchenko <yantar92 <at> gmail.com>
> Date: Mon, 16 Dec 2019 14:42:38 +0800
> 
> When I try to create a named thread like
> 
> (make-thread (lambda () (+ 1 2)) "test-emacs-async")
> 
> the emacs process gets renamed to "test-emacs-async" even after the
> thread returns. Making another thread with different name renames emacs
> process again.

I think, instead of calling prctl in systhread.c, we should call
pthread_set_name_np, and the configure-time test for prctl should be
replaced with a test for pthread_set_name_np.

Patches welcome.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Wed, 18 Dec 2019 09:07:01 GMT) Full text and rfc822 format available.

Message #11 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 38632 <at> debbugs.gnu.org, Ihor Radchenko <yantar92 <at> gmail.com>
Subject: Re: bug#38632: 27.0.50; Emacs process name is changed permanently
 upon creating a named thread
Date: Wed, 18 Dec 2019 10:05:58 +0100
>>>>> On Tue, 17 Dec 2019 22:05:52 +0200, Eli Zaretskii <eliz <at> gnu.org> said:

    >> From: Ihor Radchenko <yantar92 <at> gmail.com>
    >> Date: Mon, 16 Dec 2019 14:42:38 +0800
    >> 
    >> When I try to create a named thread like
    >> 
    >> (make-thread (lambda () (+ 1 2)) "test-emacs-async")
    >> 
    >> the emacs process gets renamed to "test-emacs-async" even after the
    >> thread returns. Making another thread with different name renames emacs
    >> process again.

    Eli> I think, instead of calling prctl in systhread.c, we should call
    Eli> pthread_set_name_np, and the configure-time test for prctl should be
    Eli> replaced with a test for pthread_set_name_np.

Would it not be easier to call prctl in the context of the created
thread? That way it deals with the name length issues for us:
pthread_setname_np fails if strlen(name) >= 16, wherease prctl
truncates.

Robert




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Wed, 18 Dec 2019 15:55:02 GMT) Full text and rfc822 format available.

Message #14 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 38632 <at> debbugs.gnu.org, yantar92 <at> gmail.com
Subject: Re: bug#38632: 27.0.50; Emacs process name is changed permanently
 upon creating a named thread
Date: Wed, 18 Dec 2019 17:53:49 +0200
> From: Robert Pluim <rpluim <at> gmail.com>
> Cc: Ihor Radchenko <yantar92 <at> gmail.com>,  38632 <at> debbugs.gnu.org
> Date: Wed, 18 Dec 2019 10:05:58 +0100
> 
>     Eli> I think, instead of calling prctl in systhread.c, we should call
>     Eli> pthread_set_name_np, and the configure-time test for prctl should be
>     Eli> replaced with a test for pthread_set_name_np.
> 
> Would it not be easier to call prctl in the context of the created
> thread? That way it deals with the name length issues for us:
> pthread_setname_np fails if strlen(name) >= 16, wherease prctl
> truncates.

AFAIU, prctl is Linux-specific, whereas pthread_setname_np is
supported on other Posix platforms that provide pthreads.  Also, prctl
has another disadvantage, in that it requires you to pass the name to
the thread being created, or put it in some global.  OTOH, truncating
a string is not exactly rocket science, we can do that ourselves
before calling the API.

(Btw, the limitation is 16 bytes, including the terminating null, so
truncation needs to be clever about non-ASCII characters, and I wonder
what does prctl do when 15 bytes end in the middle of a multibyte
sequence.)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Wed, 18 Dec 2019 17:06:02 GMT) Full text and rfc822 format available.

Message #17 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 38632 <at> debbugs.gnu.org, yantar92 <at> gmail.com
Subject: Re: bug#38632: 27.0.50; Emacs process name is changed permanently
 upon creating a named thread
Date: Wed, 18 Dec 2019 18:04:53 +0100
>>>>> On Wed, 18 Dec 2019 17:53:49 +0200, Eli Zaretskii <eliz <at> gnu.org> said:

    Eli> AFAIU, prctl is Linux-specific, whereas pthread_setname_np is
    Eli> supported on other Posix platforms that provide pthreads.  Also, prctl
    Eli> has another disadvantage, in that it requires you to pass the name to
    Eli> the thread being created, or put it in some global.  OTOH, truncating
    Eli> a string is not exactly rocket science, we can do that ourselves
    Eli> before calling the API.

We already use a wrapper function to call the user-supplied function,
so prctl could be added there, but the wider availability of
pthread_setname_np weighs in its favour.

    Eli> (Btw, the limitation is 16 bytes, including the terminating null, so
    Eli> truncation needs to be clever about non-ASCII characters, and I wonder
    Eli> what does prctl do when 15 bytes end in the middle of a multibyte
    Eli> sequence.)

It does exactly what you'd expect, it drops the extraneous bytes, so
putting eg ü on the boundary results in a name ending in à (#xc3).

In any case, if emacs or prctl truncates, then the name as reported
by 'list-threads' will be out of sync with pthread_getname_np, unless
you'd want to adjust that too.

Robert




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Wed, 18 Dec 2019 17:20:01 GMT) Full text and rfc822 format available.

Message #20 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 38632 <at> debbugs.gnu.org, yantar92 <at> gmail.com
Subject: Re: bug#38632: 27.0.50; Emacs process name is changed permanently
 upon creating a named thread
Date: Wed, 18 Dec 2019 19:18:57 +0200
> From: Robert Pluim <rpluim <at> gmail.com>
> Cc: yantar92 <at> gmail.com,  38632 <at> debbugs.gnu.org
> Date: Wed, 18 Dec 2019 18:04:53 +0100
> 
>     Eli> (Btw, the limitation is 16 bytes, including the terminating null, so
>     Eli> truncation needs to be clever about non-ASCII characters, and I wonder
>     Eli> what does prctl do when 15 bytes end in the middle of a multibyte
>     Eli> sequence.)
> 
> It does exactly what you'd expect, it drops the extraneous bytes, so
> putting eg ü on the boundary results in a name ending in à (#xc3).

So it is one more reason to do or own truncation, so we do it right.

> In any case, if emacs or prctl truncates, then the name as reported
> by 'list-threads' will be out of sync with pthread_getname_np, unless
> you'd want to adjust that too.

We need to truncate the names we store in the thread object (and
document that).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Wed, 18 Dec 2019 21:31:01 GMT) Full text and rfc822 format available.

Message #23 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 38632 <at> debbugs.gnu.org, yantar92 <at> gmail.com
Subject: Re: bug#38632: 27.0.50; Emacs process name is changed permanently
 upon creating a named thread
Date: Wed, 18 Dec 2019 22:30:14 +0100
>>>>> On Wed, 18 Dec 2019 19:18:57 +0200, Eli Zaretskii <eliz <at> gnu.org> said:

    >> From: Robert Pluim <rpluim <at> gmail.com>
    >> Cc: yantar92 <at> gmail.com,  38632 <at> debbugs.gnu.org
    >> Date: Wed, 18 Dec 2019 18:04:53 +0100
    >> 
    Eli> (Btw, the limitation is 16 bytes, including the terminating null, so
    Eli> truncation needs to be clever about non-ASCII characters, and I wonder
    Eli> what does prctl do when 15 bytes end in the middle of a multibyte
    Eli> sequence.)
    >> 
    >> It does exactly what you'd expect, it drops the extraneous bytes, so
    >> putting eg ü on the boundary results in a name ending in à (#xc3).

    Eli> So it is one more reason to do or own truncation, so we do it right.

OK. Is there a useful function that would help for that? I can cook up
something based on NEXT_CHAR_BOUNDARY and/or BYTES_BY_CHAR_HEAD, but Iʼd
expect there to be something already.

    >> In any case, if emacs or prctl truncates, then the name as reported
    >> by 'list-threads' will be out of sync with pthread_getname_np, unless
    >> you'd want to adjust that too.

    Eli> We need to truncate the names we store in the thread object (and
    Eli> document that).

Thatʼs the easy part. Iʼm assuming mswindows doesnʼt truncate.

Robert






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Thu, 19 Dec 2019 15:12:01 GMT) Full text and rfc822 format available.

Message #26 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 38632 <at> debbugs.gnu.org, yantar92 <at> gmail.com
Subject: Re: bug#38632: 27.0.50; Emacs process name is changed permanently
 upon creating a named thread
Date: Thu, 19 Dec 2019 17:11:24 +0200
> From: Robert Pluim <rpluim <at> gmail.com>
> Cc: 38632 <at> debbugs.gnu.org,  yantar92 <at> gmail.com
> Date: Wed, 18 Dec 2019 22:30:14 +0100
> 
>     >> It does exactly what you'd expect, it drops the extraneous bytes, so
>     >> putting eg ü on the boundary results in a name ending in à (#xc3).
> 
>     Eli> So it is one more reason to do or own truncation, so we do it right.
> 
> OK. Is there a useful function that would help for that? I can cook up
> something based on NEXT_CHAR_BOUNDARY and/or BYTES_BY_CHAR_HEAD, but Iʼd
> expect there to be something already.

No, the above two and their ilk (PREV_CHAR_BOUNDARY etc.) are what we
use.

>     >> In any case, if emacs or prctl truncates, then the name as reported
>     >> by 'list-threads' will be out of sync with pthread_getname_np, unless
>     >> you'd want to adjust that too.
> 
>     Eli> We need to truncate the names we store in the thread object (and
>     Eli> document that).

I think I'm going to change my mind on that.  The complication here is
that the name should be encoded by ENCODE_SYSTEM before we pass it to
pthread_setname_np etc., and if the locale-coding-system is not UTF-8
and not single-byte, we don't really know where a character will end
after encoding.  And encoding one character at a time sounds too
gross.

So perhaps we should just truncate the bytes, and leave this to the
application to make sure the result makes sense, and also disregard
the difference between list-threads and the thread name as the OS and
debuggers see it.  Doing that will also avoid the complication of
having the thread name return to the caller different from what the
caller used.

WDYT?

> Iʼm assuming mswindows doesnʼt truncate.

MS-Windows currently doesn't support setting thread names at all;
maybe I'll write something soon to fix that.  But yes, I cannot find
any documentation stating any limits there.  GDB on Windows reads the
first 1024 bytes of the thread name, so maybe we should document that
this is the recommended maximum on any platform.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Thu, 19 Dec 2019 16:43:02 GMT) Full text and rfc822 format available.

Message #29 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 38632 <at> debbugs.gnu.org, yantar92 <at> gmail.com
Subject: Re: bug#38632: 27.0.50; Emacs process name is changed permanently
 upon creating a named thread
Date: Thu, 19 Dec 2019 17:42:41 +0100
[Message part 1 (text/plain, inline)]
>>>>> On Thu, 19 Dec 2019 17:11:24 +0200, Eli Zaretskii <eliz <at> gnu.org> said:
    Eli> We need to truncate the names we store in the thread object (and
    Eli> document that).

    Eli> I think I'm going to change my mind on that.  The complication here is
    Eli> that the name should be encoded by ENCODE_SYSTEM before we pass it to
    Eli> pthread_setname_np etc., and if the locale-coding-system is not UTF-8
    Eli> and not single-byte, we don't really know where a character will end
    Eli> after encoding.  And encoding one character at a time sounds too
    Eli> gross.

    Eli> So perhaps we should just truncate the bytes, and leave this to the
    Eli> application to make sure the result makes sense, and also disregard
    Eli> the difference between list-threads and the thread name as the OS and
    Eli> debuggers see it.  Doing that will also avoid the complication of
    Eli> having the thread name return to the caller different from what the
    Eli> caller used.

Hereʼs what it looks like.

[0001-Use-pthread_setname_np-to-set-thread-name.patch (text/x-patch, inline)]
From bbb7e7837fcad3bac10aef69a1b331243c2b1c4c Mon Sep 17 00:00:00 2001
From: Robert Pluim <rpluim <at> gmail.com>
Date: Thu, 19 Dec 2019 17:33:16 +0100
Subject: [PATCH] Use pthread_setname_np to set thread name

* configure.ac: Remove check for sys/prctl.h and prctl, check for
pthread_setname_np instead.

* systhread.c: Remove sys/prctl.h include.
(sys_thread_create) [HAVE_PTHREAD_SETNAME_NP]: Use pthread_setname_np
to set the name of the newly created thread (Bug#38632).
---
 configure.ac    |  4 ++--
 src/systhread.c | 17 +++++++++++------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/configure.ac b/configure.ac
index 3b6a2a6d16..34a2654494 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1767,7 +1767,7 @@ AC_DEFUN
   sys/sysinfo.h
   coff.h pty.h
   sys/resource.h
-  sys/utsname.h pwd.h utmp.h util.h sys/prctl.h)
+  sys/utsname.h pwd.h utmp.h util.h)
 
 AC_CACHE_CHECK([for ADDR_NO_RANDOMIZE],
   [emacs_cv_personality_addr_no_randomize],
@@ -4180,7 +4180,7 @@ AC_DEFUN
 sendto recvfrom getsockname getifaddrs freeifaddrs \
 gai_strerror sync \
 getpwent endpwent getgrent endgrent \
-cfmakeraw cfsetspeed __executable_start log2 prctl)
+cfmakeraw cfsetspeed __executable_start log2 pthread_setname_np)
 LIBS=$OLD_LIBS
 
 dnl No need to check for posix_memalign if aligned_alloc works.
diff --git a/src/systhread.c b/src/systhread.c
index 6f4de536fb..55bde837e3 100644
--- a/src/systhread.c
+++ b/src/systhread.c
@@ -98,10 +98,6 @@ sys_thread_yield (void)
 
 #include <sched.h>
 
-#ifdef HAVE_SYS_PRCTL_H
-#include <sys/prctl.h>
-#endif
-
 void
 sys_mutex_init (sys_mutex_t *mutex)
 {
@@ -227,9 +223,18 @@ sys_thread_create (sys_thread_t *thread_ptr, const char *name,
   if (!pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED))
     {
       result = pthread_create (thread_ptr, &attr, func, arg) == 0;
-#if defined (HAVE_SYS_PRCTL_H) && defined (HAVE_PRCTL) && defined (PR_SET_NAME)
+#ifdef HAVE_PTHREAD_SETNAME_NP
       if (result && name != NULL)
-	prctl (PR_SET_NAME, name);
+        {
+          /* We need to truncate here otherwise pthread_setname_np
+             fails to set the name.  TASK_COMM_LEN is what the length
+             is called in the Linux kernel headers (Bug#38632).  */
+#define TASK_COMM_LEN 16
+          char p_name[TASK_COMM_LEN];
+          strncpy (p_name, name, TASK_COMM_LEN - 1);
+          p_name[TASK_COMM_LEN - 1] = '\0';
+          pthread_setname_np (*thread_ptr, p_name);
+        }
 #endif
     }
 
-- 
2.23.0


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Thu, 19 Dec 2019 18:57:02 GMT) Full text and rfc822 format available.

Message #32 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 38632 <at> debbugs.gnu.org, yantar92 <at> gmail.com
Subject: Re: bug#38632: 27.0.50; Emacs process name is changed permanently
 upon creating a named thread
Date: Thu, 19 Dec 2019 20:56:33 +0200
> From: Robert Pluim <rpluim <at> gmail.com>
> Cc: 38632 <at> debbugs.gnu.org,  yantar92 <at> gmail.com
> Date: Thu, 19 Dec 2019 17:42:41 +0100
> 
> Hereʼs what it looks like.

Thanks, but I think we need to change thread.c to use ENCODE_SYSTEM
instead of ENCODE_UTF_8, since the name should be passed encoded in
the locale's codeset.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Fri, 20 Dec 2019 19:15:02 GMT) Full text and rfc822 format available.

Message #35 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: rpluim <at> gmail.com
Cc: 38632 <at> debbugs.gnu.org, yantar92 <at> gmail.com
Subject: Re: bug#38632: 27.0.50;
 Emacs process name is changed permanently upon creating a named thread
Date: Fri, 20 Dec 2019 21:13:59 +0200
> Date: Thu, 19 Dec 2019 17:11:24 +0200
> From: Eli Zaretskii <eliz <at> gnu.org>
> Cc: 38632 <at> debbugs.gnu.org, yantar92 <at> gmail.com
> 
> MS-Windows currently doesn't support setting thread names at all;
> maybe I'll write something soon to fix that.

Now done.

I'd appreciate testing on 64-bit Windows and in particular on Windows
10.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Mon, 06 Jan 2020 14:44:01 GMT) Full text and rfc822 format available.

Message #38 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 38632 <at> debbugs.gnu.org, yantar92 <at> gmail.com
Subject: Re: bug#38632: 27.0.50; Emacs process name is changed permanently
 upon creating a named thread
Date: Mon, 06 Jan 2020 15:43:39 +0100
>>>>> On Fri, 20 Dec 2019 21:13:59 +0200, Eli Zaretskii <eliz <at> gnu.org> said:

    >> Date: Thu, 19 Dec 2019 17:11:24 +0200
    >> From: Eli Zaretskii <eliz <at> gnu.org>
    >> Cc: 38632 <at> debbugs.gnu.org, yantar92 <at> gmail.com
    >> 
    >> MS-Windows currently doesn't support setting thread names at all;
    >> maybe I'll write something soon to fix that.

    Eli> Now done.

    Eli> I'd appreciate testing on 64-bit Windows and in particular on Windows
    Eli> 10.

It builds fine on Windows 10 using mingw64, and I can create a
thread with a name, which 'info threads' in gdb then displays
correctly.

GNU/Linux version pushed to emacs-27.

Robert




bug marked as fixed in version 27.1, send any further explanations to 38632 <at> debbugs.gnu.org and Ihor Radchenko <yantar92 <at> gmail.com> Request was from Robert Pluim <rpluim <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 06 Jan 2020 14:46:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Mon, 06 Jan 2020 16:23:01 GMT) Full text and rfc822 format available.

Message #43 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 38632 <at> debbugs.gnu.org, yantar92 <at> gmail.com
Subject: Re: bug#38632: 27.0.50; Emacs process name is changed permanently
 upon creating a named thread
Date: Mon, 06 Jan 2020 18:22:32 +0200
> From: Robert Pluim <rpluim <at> gmail.com>
> Cc: 38632 <at> debbugs.gnu.org,  yantar92 <at> gmail.com
> Date: Mon, 06 Jan 2020 15:43:39 +0100
> 
>     Eli> I'd appreciate testing on 64-bit Windows and in particular on Windows
>     Eli> 10.
> 
> It builds fine on Windows 10 using mingw64, and I can create a
> thread with a name, which 'info threads' in gdb then displays
> correctly.
> 
> GNU/Linux version pushed to emacs-27.

Great, thanks (on both counts).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Mon, 06 Jan 2020 19:51:01 GMT) Full text and rfc822 format available.

Message #46 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Mattias Engdegård <mattiase <at> acm.org>
To: 38632 <at> debbugs.gnu.org
Cc: Eli Zaretskii <eliz <at> gnu.org>, Robert Pluim <rpluim <at> gmail.com>
Subject: bug#38632: 27.0.50; Emacs process name is changed permanently  upon
 creating a named thread
Date: Mon, 6 Jan 2020 20:50:44 +0100
reopen 38632
stop

The committed patch fails to compile on macOS (10.14). Here, and probably BSD in general, pthread_setname_np takes a single argument (the name) and applies to the current thread.





bug No longer marked as fixed in versions 27.1 and reopened. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 06 Jan 2020 19:51:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Mon, 06 Jan 2020 21:59:01 GMT) Full text and rfc822 format available.

Message #51 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Mattias Engdegård <mattiase <at> acm.org>
To: 38632 <at> debbugs.gnu.org
Cc: Eli Zaretskii <eliz <at> gnu.org>, Robert Pluim <rpluim <at> gmail.com>
Subject: Re: bug#38632: 27.0.50; Emacs process name is changed permanently 
 upon creating a named thread
Date: Mon, 6 Jan 2020 22:58:25 +0100
[Message part 1 (text/plain, inline)]
Here is a quick-and-dirty patch that repairs the macOS/BSD builds. Not tested on anything else.

[pthread-setname.diff (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Mon, 06 Jan 2020 22:22:01 GMT) Full text and rfc822 format available.

Message #54 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: 38632 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#38632: 27.0.50; Emacs process name is changed permanently
 upon creating a named thread
Date: Mon, 06 Jan 2020 23:21:07 +0100
>>>>> On Mon, 6 Jan 2020 20:50:44 +0100, Mattias Engdegård <mattiase <at> acm.org> said:

    Mattias> reopen 38632
    Mattias> stop

    Mattias> The committed patch fails to compile on macOS (10.14). Here, and
    Mattias> probably BSD in general, pthread_setname_np takes a single argument
    Mattias> (the name) and applies to the current thread.

Bother.

Eli, what do you want to do here? I can rework the configure test to
check for the 2-arg version of pthread_setname_np, or we could revert
the change.

Robert




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Mon, 06 Jan 2020 23:07:02 GMT) Full text and rfc822 format available.

Message #57 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: 38632 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#38632: 27.0.50; Emacs process name is changed permanently
 upon creating a named thread
Date: Tue, 07 Jan 2020 00:06:00 +0100
>>>>> On Mon, 6 Jan 2020 22:58:25 +0100, Mattias Engdegård <mattiase <at> acm.org> said:

    Mattias> Here is a quick-and-dirty patch that repairs the macOS/BSD builds. Not tested on anything else.

That builds and works fine for me on Fedora. Thanks for fixing that.

Robert




Merged 38632 39003. Request was from Robert Pluim <rpluim <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 07 Jan 2020 12:15:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Tue, 07 Jan 2020 15:46:01 GMT) Full text and rfc822 format available.

Message #62 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: 38632 <at> debbugs.gnu.org, rpluim <at> gmail.com
Subject: Re: bug#38632: 27.0.50; Emacs process name is changed permanently 
 upon creating a named thread
Date: Tue, 07 Jan 2020 17:45:36 +0200
> From: Mattias Engdegård <mattiase <at> acm.org>
> Date: Mon, 6 Jan 2020 22:58:25 +0100
> Cc: Eli Zaretskii <eliz <at> gnu.org>, Robert Pluim <rpluim <at> gmail.com>
> 
> Here is a quick-and-dirty patch that repairs the macOS/BSD builds. Not tested on anything else.

Thanks.  This is fine for the emacs-27 branch, but it needs some minor
cleanup:

> -static thread_creation_function *thread_start_address;

This line cannot be deleted, as it will cause systhread.c fail to
compile on MS-Windows.

And this comment on thread.h:

  /* Thread's name in the locale encoding.  Actually used only on
     WINDOWSNT.  */
  char *thread_name;

is no longer accurate, so it needs to be updated to reflect the
modified code.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Tue, 07 Jan 2020 16:47:02 GMT) Full text and rfc822 format available.

Message #65 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Mattias Engdegård <mattiase <at> acm.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 38632 <at> debbugs.gnu.org, rpluim <at> gmail.com
Subject: Re: bug#38632: 27.0.50; Emacs process name is changed permanently 
 upon creating a named thread
Date: Tue, 7 Jan 2020 17:46:49 +0100
[Message part 1 (text/plain, inline)]
7 jan. 2020 kl. 16.45 skrev Eli Zaretskii <eliz <at> gnu.org>:

> This line cannot be deleted, as it will cause systhread.c fail to
> compile on MS-Windows.

Oops! Reinstated.

However, isn't thread_start_address inherently racy? It doesn't matter much since it will only ever have a single value (run_thread), but it does violate layering. That problem won't be addressed in this patch, however.

> And this comment on thread.h:

Edited.

Thanks for the review! Patch updated.

[0001-Fix-BSD-and-macOS-builds-w.r.t.-pthread_setname_np-b.patch (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Tue, 07 Jan 2020 17:06:02 GMT) Full text and rfc822 format available.

Message #68 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: 38632 <at> debbugs.gnu.org, rpluim <at> gmail.com
Subject: Re: bug#38632: 27.0.50; Emacs process name is changed permanently 
 upon creating a named thread
Date: Tue, 07 Jan 2020 19:05:53 +0200
> From: Mattias Engdegård <mattiase <at> acm.org>
> Date: Tue, 7 Jan 2020 17:46:49 +0100
> Cc: 38632 <at> debbugs.gnu.org, rpluim <at> gmail.com
> 
> Thanks for the review! Patch updated.

LGTM, thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Tue, 07 Jan 2020 17:07:01 GMT) Full text and rfc822 format available.

Message #71 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: 38632 <at> debbugs.gnu.org, rpluim <at> gmail.com
Subject: Re: bug#38632: 27.0.50; Emacs process name is changed permanently 
 upon creating a named thread
Date: Tue, 07 Jan 2020 19:07:05 +0200
> From: Mattias Engdegård <mattiase <at> acm.org>
> Date: Tue, 7 Jan 2020 17:46:49 +0100
> Cc: 38632 <at> debbugs.gnu.org, rpluim <at> gmail.com
> 
> However, isn't thread_start_address inherently racy? It doesn't matter much since it will only ever have a single value (run_thread), but it does violate layering. That problem won't be addressed in this patch, however.

Yes, that should be a separate cleanup (and yes, we always set it to
the same function, so the race shouldn't matter in practice).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Tue, 07 Jan 2020 17:20:01 GMT) Full text and rfc822 format available.

Message #74 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Mattias Engdegård <mattiase <at> acm.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 38632 <at> debbugs.gnu.org, rpluim <at> gmail.com
Subject: Re: bug#38632: 27.0.50; Emacs process name is changed permanently 
 upon creating a named thread
Date: Tue, 7 Jan 2020 18:19:04 +0100
7 jan. 2020 kl. 18.07 skrev Eli Zaretskii <eliz <at> gnu.org>:

> Yes, that should be a separate cleanup (and yes, we always set it to
> the same function, so the race shouldn't matter in practice).

Right. Just to be clear, I'm not going to do that since I don't have a Windows development setup.





bug marked as fixed in version 27.1, send any further explanations to 38632 <at> debbugs.gnu.org and Ihor Radchenko <yantar92 <at> gmail.com> Request was from Mattias Engdegård <mattiase <at> acm.org> to control <at> debbugs.gnu.org. (Tue, 07 Jan 2020 18:07:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Wed, 08 Jan 2020 18:27:02 GMT) Full text and rfc822 format available.

Message #79 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: 38632 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, rpluim <at> gmail.com
Subject: Re: bug#38632: 27.0.50;
 Emacs process name is changed permanently upon creating a named thread
Date: Wed, 08 Jan 2020 13:26:16 -0500
73fd8a4 fails to build on some GNU/Linux hosts, ref eg

https://hydra.nixos.org/build/109904668
  
  systhread.c:86:1: error: conflicting types for 'sys_thread_create'
   sys_thread_create (sys_thread_t *t, const char *name,
   ^~~~~~~~~~~~~~~~~
  In file included from thread.h:33:0,
                   from lisp.h:2163,
                   from systhread.c:23:
  systhread.h:115:13: note: previous declaration of 'sys_thread_create' was here
   extern bool sys_thread_create (sys_thread_t *, thread_creation_function *,
               ^~~~~~~~~~~~~~~~~
  make[1]: *** [Makefile:402: systhread.o] Error 1




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Wed, 08 Jan 2020 18:55:02 GMT) Full text and rfc822 format available.

Message #82 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: mattiase <at> acm.org, rpluim <at> gmail.com, 38632 <at> debbugs.gnu.org
Subject: Re: bug#38632: 27.0.50;
 Emacs process name is changed permanently upon creating a named thread
Date: Wed, 08 Jan 2020 20:54:22 +0200
> From: Glenn Morris <rgm <at> gnu.org>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  38632 <at> debbugs.gnu.org,  rpluim <at> gmail.com
> Date: Wed, 08 Jan 2020 13:26:16 -0500
> 
> 
> 73fd8a4 fails to build on some GNU/Linux hosts, ref eg
> 
> https://hydra.nixos.org/build/109904668
>   
>   systhread.c:86:1: error: conflicting types for 'sys_thread_create'
>    sys_thread_create (sys_thread_t *t, const char *name,
>    ^~~~~~~~~~~~~~~~~
>   In file included from thread.h:33:0,
>                    from lisp.h:2163,
>                    from systhread.c:23:
>   systhread.h:115:13: note: previous declaration of 'sys_thread_create' was here
>    extern bool sys_thread_create (sys_thread_t *, thread_creation_function *,
>                ^~~~~~~~~~~~~~~~~
>   make[1]: *** [Makefile:402: systhread.o] Error 1

Thanks, should be fixed now.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Wed, 08 Jan 2020 19:35:02 GMT) Full text and rfc822 format available.

Message #85 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: mattiase <at> acm.org, rpluim <at> gmail.com, 38632 <at> debbugs.gnu.org
Subject: Re: bug#38632: 27.0.50;
 Emacs process name is changed permanently upon creating a named thread
Date: Wed, 08 Jan 2020 14:34:48 -0500
Now a different problem:

thread.o: In function `run_thread':
/build/1rjrmrn0sv17hak6ql2igch5f221shf2-source/src/thread.c:729:
undefined reference to `sys_thread_set_name'

Ref: https://hydra.nixos.org/build/109906136




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38632; Package emacs. (Wed, 08 Jan 2020 20:02:01 GMT) Full text and rfc822 format available.

Message #88 received at 38632 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: mattiase <at> acm.org, rpluim <at> gmail.com, 38632 <at> debbugs.gnu.org
Subject: Re: bug#38632: 27.0.50;
 Emacs process name is changed permanently upon creating a named thread
Date: Wed, 08 Jan 2020 22:01:53 +0200
> From: Glenn Morris <rgm <at> gnu.org>
> Cc: mattiase <at> acm.org,  38632 <at> debbugs.gnu.org,  rpluim <at> gmail.com
> Date: Wed, 08 Jan 2020 14:34:48 -0500
> 
> Now a different problem:
> 
> thread.o: In function `run_thread':
> /build/1rjrmrn0sv17hak6ql2igch5f221shf2-source/src/thread.c:729:
> undefined reference to `sys_thread_set_name'

Fixed.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 06 Feb 2020 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 78 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.