From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel Clemente Newsgroups: gmane.emacs.bugs Subject: bug#71694: 30.0.50; heap-use-after-free in tty_defined_color Date: Wed, 26 Jun 2024 13:29:08 +0000 Message-ID: References: <864j9ml6j1.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33464"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 71694@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 26 15:31:10 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sMSju-0008WN-O2 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 26 Jun 2024 15:31:10 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMSjq-0000mJ-Ff; Wed, 26 Jun 2024 09:31:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMSjk-0000jE-PA for bug-gnu-emacs@gnu.org; Wed, 26 Jun 2024 09:31:00 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMSjk-0003Qh-FT for bug-gnu-emacs@gnu.org; Wed, 26 Jun 2024 09:31:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sMSjm-0000Ms-Nh for bug-gnu-emacs@gnu.org; Wed, 26 Jun 2024 09:31:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Daniel Clemente Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Jun 2024 13:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71694 X-GNU-PR-Package: emacs Original-Received: via spool by 71694-submit@debbugs.gnu.org id=B71694.17194086511378 (code B ref 71694); Wed, 26 Jun 2024 13:31:02 +0000 Original-Received: (at 71694) by debbugs.gnu.org; 26 Jun 2024 13:30:51 +0000 Original-Received: from localhost ([127.0.0.1]:38815 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sMSja-0000M9-CO for submit@debbugs.gnu.org; Wed, 26 Jun 2024 09:30:50 -0400 Original-Received: from mail-ej1-f49.google.com ([209.85.218.49]:53570) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sMSjX-0000Lp-JE for 71694@debbugs.gnu.org; Wed, 26 Jun 2024 09:30:48 -0400 Original-Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a725041ad74so212794566b.3 for <71694@debbugs.gnu.org>; Wed, 26 Jun 2024 06:30:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719408579; x=1720013379; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Wr1BNOSjfMRUlyuvqm2IKkE5ElyBMMutjCm+UTtD0gw=; b=Sc9chpxBYo32aXC0kGLyL27RQ3m7FaNfIny40GCgaqdbLnFiPFcrPrXCutKrY1ZVuM qkKT+yMk4ua3fxJ1FsX6VI6NZxcS9bQw/So8jqga7nK+QDc7igLjGhfLU9qUx28t9Tlh CtHX+bYUFt+tWT2HHR4BcsCGAQ4/ZaIDC28m2nIiSKpeKJj+hzpNnnjYPr5kfT4iULYb y4rl+weFdcW/5MA7PuPiUhO9YcIJbt4Hu0WT1IQKf39YX1GcXDMRvT14cOysR9FDpLuk Rj0wnVVg2ExBMHwye9kvyakGSdQdwPrFKwmd8MQ/lUQOD8eiEGbWswjBr1uaDiZnnSoZ qiDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719408579; x=1720013379; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wr1BNOSjfMRUlyuvqm2IKkE5ElyBMMutjCm+UTtD0gw=; b=TjUANyxc3M/eeAW0jJjKs7IJh0vGY3jYnfSEV2v4kUA4lLcof+5gelzCzKBvCjm2pl zRVz2p4aDULVs8yoVGu1IXKsRZwNYoXuMlmUaTTZ4/E/xT3JdCo2+4n+jwLnZQu00hbN 809Mkjbs7XFWnn9xeNOtXhSzubB4eq+wtYWwf/o6+UhqldgISVwt85K71kBWnV7voFF7 wopBv1U3t1NkRcbS5n96JE2jjN8CQ4igjXXnQXl0TU6pHsmGe92bC83bh0EcI2Wlxidi f6+tdluWTlI8KoGxSkI/I7CGnl5Njde34CUxulwgmkJgl0JSo3oqZqyfBWkXZ8WwKR/m wnAQ== X-Gm-Message-State: AOJu0Yw1McJRteBh0L+Wt4Fo3zNGlBAPN9FyMRhdFFzTKN91Nsyq7LKh ZLZZNzwgoo6QHw482QqRwmht5kO+mzlK4rArCfXcHL/qrLh8qF5Ul5twnkLCAkFkwd1X/vv2Jlw bE9BIb6bao0SNUWqVYKfSgijnDCrZNKOz X-Google-Smtp-Source: AGHT+IGZPTkoujUWPHm99JBAsi4eIpZol7dy6esM3gEuPpW9OIBTJJv7zVmiiVW226ZusdReDWGX8oXK8YDJh9i+QZc= X-Received: by 2002:a50:9546:0:b0:579:d673:4e67 with SMTP id 4fb4d7f45d1cf-57d70069b8bmr5580334a12.26.1719408579364; Wed, 26 Jun 2024 06:29:39 -0700 (PDT) In-Reply-To: <864j9ml6j1.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:287942 Archived-At: On Fri, 21 Jun 2024 at 14:22, Eli Zaretskii wrote: > > > From: Daniel Clemente > > Date: Fri, 21 Jun 2024 10:47:01 +0000 > > > > I enabled -fsanitize. I'm using an X terminal to run TTY Emacs inside. > > I opened the daemon inside gdb with emacs --fg-daemon -Q > > > > I don't remember what exactly I was doing here, but it only involved > > slowly opening 2 or 3 terminals like this > > urxvt -e "emacsclient" "-c" "-e" '(dired "~")' > > and then I might have opened 2 or 3 with this (in the same session) > > xterm -e "emacsclient" "-c" "-e" '(dired "~")' > > Plus switching between them and closing them. > > However that's not a reproduction formula, it's just what I was doing > > when this crash randomly happened. I don't know how to reproduce this > > yet. > > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > =3D=3D9677=3D=3DERROR: AddressSanitizer: heap-use-after-free on address > > 0x625000123b30 at pc 0x55555695b2c9 bp 0x7fffffff9900 sp > > 0x7fffffff98f8 > > READ of size 1 at 0x625000123b30 thread T0 > > #0 0x55555695b2c8 in tty_defined_color /w/emacs/src/xfaces.c:1115 > > I think this is bogus: -fsanitize doesn't understand the Emacs memory > management, in particular what's going in GC when we relocate strings. > I also used -fsanitize=3Dundefined,address,bounds-strict,float-cast-overflo= w without realizing that undefined+address seem to be incompatible; sorry. This -fsanitize =E2=80=9Enot understanding=E2=80=9C memory management could= be explained in etc/DEBUG. But this seems advanced so I guess developers should just get more experience in Emacs memory management before enabling this. (You can close it you want). > In any case, the line numbers seem off: line 1115 of xfaces.c is a > comment. Are your sources in sync with the Git repository? My sources were synchronized but my build was a few weeks old: d9512da49514623ef3e35524dc894c06f2c0ce20 Line 1115 of xfaces.c was: if (color_def->pixel =3D=3D FACE_TTY_DEFAULT_COLOR && *color_name) in this context: /* Defaults. */ color_def->pixel =3D FACE_TTY_DEFAULT_COLOR; color_def->red =3D 0; color_def->blue =3D 0; color_def->green =3D 0; if (*color_name) status =3D tty_lookup_color (f, build_string (color_name), color_def, N= ULL); if (color_def->pixel =3D=3D FACE_TTY_DEFAULT_COLOR && *color_name) { if (strcmp (color_name, "unspecified-fg") =3D=3D 0) color_def->pixel =3D FACE_TTY_DEFAULT_FG_COLOR; else if (strcmp (color_name, "unspecified-bg") =3D=3D 0) color_def->pixel =3D FACE_TTY_DEFAULT_BG_COLOR; }