From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Gerd_M=C3=B6llmann?= Newsgroups: gmane.emacs.devel Subject: Re: MPS: a random backtrace while toying with gdb Date: Sun, 30 Jun 2024 11:43:56 +0200 Message-ID: References: <87bk3jh8bt.fsf@localhost> <867ce7hvvz.fsf@gnu.org> <86tthbgdlr.fsf@gnu.org> <86r0cehkwr.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26274"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: pipcet@protonmail.com, yantar92@posteo.net, emacs-devel@gnu.org, eller.helmut@gmail.com To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jun 30 11:44:43 2024 Return-path: Envelope-to: ged-emacs-devel@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 1sNr6w-0006ga-P1 for ged-emacs-devel@m.gmane-mx.org; Sun, 30 Jun 2024 11:44:42 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sNr6I-0006h8-QP; Sun, 30 Jun 2024 05:44:02 -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 1sNr6H-0006gz-O0 for emacs-devel@gnu.org; Sun, 30 Jun 2024 05:44:01 -0400 Original-Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sNr6G-0007KF-0Z; Sun, 30 Jun 2024 05:44:01 -0400 Original-Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a689ad8d1f6so235683666b.2; Sun, 30 Jun 2024 02:43:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719740638; x=1720345438; darn=gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=mRHfMJpI5HT8yO7b9PZNOpZK9FzIgUdOKcU855c8bf0=; b=CZnO+CSBOchcXxUyxhP346sCe1f4D6uHZdRvSJN7LK6VRpP0/uJMsNkouK/fP9/Iey UxnuvQicReYR0XRXTQdnTX2XLbIhuMdh9JeV7D9CuUpBlhHZuDoOTNY2TY67FX71Lglx 3rdSN/CBPkjZjAU/od50NS+dJ24EenxlwiHTPCto7RIbhRSKvOgCnY1slmy3IILZLigl OBfWxA4dovqoNjU1IDx2IDwdqbdgGvp1G2iMqfAdUH1XTxnuHbdK1Z1RgFlrAfjPQy5D W2myaQwk9iQKNQHM8V+sZbKscgmLl6TaKPAzveyX6y26u5POArXznoEF1M2WHJtzEtvo 1HaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719740638; x=1720345438; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mRHfMJpI5HT8yO7b9PZNOpZK9FzIgUdOKcU855c8bf0=; b=wRT9DEtDq/DiDiz2aylUxNCqh2WWg0WXnaqhyf+IbhECDroPNIRsbAZJDQ1StUQQOi nC0tVad6kTeu8xlr3fmrGHZazKsrhw1TxN+0nBC+wvG3S7khxlEFzn52QV+Y/pNSlpVs oaYOVO/fv1P4YeYMkghgHa9uBBNuqWrwIu2rPBXFB6evSaXbstBDVX9fynTPzhtIsK1O K62uu1RyvWMKiH0dL1L9ByX1dWdCJCNFcMwwPIyHC+Sf+APKSHO13kkzuzYsMa2FA+xD COVf8cQ1QIpwm6CMQlMpeUK513JhGaqyh0xgGzukcntYudtpUYb7EKJZPFS7acV+FGoH Il5g== X-Forwarded-Encrypted: i=1; AJvYcCVXLScJNDxtEPyaw7nGZIsFs+lP6rJPMJm0eIZRbf+Nd/WuoDAH/Uy5SQsg7p0RpNDCgsO15X2FL+ZrOdFFg342/yeN X-Gm-Message-State: AOJu0Yz9szwpXjotQk75OYt7h+6Bi2p1ouSGOTRpi8rBkdDR2z4q76CZ KwhtZ9TX6z8Py+MizWztI1XVX7meafZxDVTt1VaXQrix4gXS293MkvwSDg== X-Google-Smtp-Source: AGHT+IH4caDtZuaSRIRbf8NuvWzRyxLkMcS4dHs8As9IRQoQV/0bp1oKZ3XbIqNlZw8jjhw2J3Jmiw== X-Received: by 2002:a17:906:6a1a:b0:a72:4c32:7d89 with SMTP id a640c23a62f3a-a7514440048mr231670966b.54.1719740637809; Sun, 30 Jun 2024 02:43:57 -0700 (PDT) Original-Received: from pro2.fritz.box (pd9e36a45.dip0.t-ipconnect.de. [217.227.106.69]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab0651easm229238966b.137.2024.06.30.02.43.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jun 2024 02:43:57 -0700 (PDT) In-Reply-To: <86r0cehkwr.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 30 Jun 2024 11:52:52 +0300") Received-SPF: pass client-ip=2a00:1450:4864:20::62c; envelope-from=gerd.moellmann@gmail.com; helo=mail-ej1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:320928 Archived-At: Eli Zaretskii writes: >> The program can do both, but only if the signal handler behaves. There >> is not much a signal handler is allowed to do. Portably it can do almost >> nothing. But even non-portably, it's never safe to call non-reentrant >> code. On Linux, there is a list of async-signal-safe functions one can >> call in a signal handler, others cannot be used. > > Which unsafe function did we call in this case, though? AFAICT, we > simply accessed memory that happens to be behind the barrier: > > #9 0x00007ffff3048050 in () at /lib64/libc.so.6 > #10 0x0000555555827385 in PSEUDOVECTORP (a=XIL(0x7fffeb90875d), code=9) at /home/yantar92/Git/emacs/src/lisp.h:1105 > #11 PROCESSP (a=XIL(0x7fffeb90875d)) at /home/yantar92/Git/emacs/src/process.h:212 > #12 XPROCESS (a=XIL(0x7fffeb90875d)) at /home/yantar92/Git/emacs/src/process.h:224 > #13 handle_child_signal (sig=sig@entry=17) at process.c:7660 > > Line 7660 of process.c is this: > > struct Lisp_Process *p = XPROCESS (proc); > > What "crime" did we commit here? Not a crime, but we are using a lib that we know uses barriers and functions of which get invoked when we hit such a barrier. We can't just ignore that. >> I don't expect MPS to be async-signal-safe. I find that unreasonble. >> Why would it be? Emacs's isn't either. Almost nothing is. > > See above: I'm not sure this is about async-signal-safety. > >> >> Just remembered that I won't be able to reproduce this anyway an macOS, >> >> where barriers don't use signals. >> > >> > AFAIU, this scenario is not necessarily related to barrier-related >> > signals. SIGCHLD caused us to access MPS-managed memory, which >> > violated some assertion in MPS, because the arena lock was already >> > taken. >> >> I would have to see an example where no barrier is involved. It is in >> this case. MPS is doing work, therefore holds the lock, receives SIGxy >> which it let's the client handle. The client hits a barrier, which >> invokes MPS's signal handler, which tries to acquire the lock which is >> already taken. > > Wouldn't the equivalent mechanism used on macOS also want to acquire > the arena lock in this case? If not, what will it do? I can't tell you exactly how MPS does this on macOS because I'm refusing to study their code, where possible at least. Fact is that barrier hits on macOS don't result in a signal, but are handled as Mach exceptions. Maybe their design docs have something explaining this, don't know.