From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: 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 Message-ID: <8336dg2vvn.fsf@gnu.org> References: <87bls8ojoh.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> <83y2va3efz.fsf@gnu.org> <83v9qd3a0i.fsf@gnu.org> <83mubp362m.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="216556"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 38632@debbugs.gnu.org, yantar92@gmail.com To: Robert Pluim Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 19 16:12:13 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ihxTJ-000uDC-B7 for geb-bug-gnu-emacs@m.gmane.org; Thu, 19 Dec 2019 16:12:13 +0100 Original-Received: from localhost ([::1]:43430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihxTH-0004eA-Uq for geb-bug-gnu-emacs@m.gmane.org; Thu, 19 Dec 2019 10:12:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45597) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihxT9-0004cb-Jf for bug-gnu-emacs@gnu.org; Thu, 19 Dec 2019 10:12:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihxT8-0003ii-EV for bug-gnu-emacs@gnu.org; Thu, 19 Dec 2019 10:12:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39415) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ihxT8-0003fp-7w for bug-gnu-emacs@gnu.org; Thu, 19 Dec 2019 10:12:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ihxT7-0001S2-Th for bug-gnu-emacs@gnu.org; Thu, 19 Dec 2019 10:12:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 19 Dec 2019 15:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38632 X-GNU-PR-Package: emacs Original-Received: via spool by 38632-submit@debbugs.gnu.org id=B38632.15767683005550 (code B ref 38632); Thu, 19 Dec 2019 15:12:01 +0000 Original-Received: (at 38632) by debbugs.gnu.org; 19 Dec 2019 15:11:40 +0000 Original-Received: from localhost ([127.0.0.1]:45388 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ihxSm-0001RR-Bu for submit@debbugs.gnu.org; Thu, 19 Dec 2019 10:11:40 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33583) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ihxSl-0001RF-67 for 38632@debbugs.gnu.org; Thu, 19 Dec 2019 10:11:39 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:34824) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ihxSf-00017w-SK; Thu, 19 Dec 2019 10:11:33 -0500 Original-Received: from [176.228.60.248] (port=4824 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ihxSf-0000hx-24; Thu, 19 Dec 2019 10:11:33 -0500 In-reply-to: (message from Robert Pluim on Wed, 18 Dec 2019 22:30:14 +0100) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.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" Xref: news.gmane.org gmane.emacs.bugs:173546 Archived-At: > From: Robert Pluim > Cc: 38632@debbugs.gnu.org, yantar92@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.