From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu Newsgroups: gmane.emacs.devel Subject: Re: sqlite memory allocation and async signal safety Date: Thu, 24 Mar 2022 18:21:29 +0800 Message-ID: <87sfr7abx2.fsf@yahoo.com> References: <8735j7btyj.fsf.ref@yahoo.com> <8735j7btyj.fsf@yahoo.com> <83v8w3d6cy.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="13325"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.91 (gnu/linux) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Mar 24 11:22:50 2022 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 1nXKc8-000358-F1 for ged-emacs-devel@m.gmane-mx.org; Thu, 24 Mar 2022 11:22:44 +0100 Original-Received: from localhost ([::1]:56906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nXKc6-0004GK-N3 for ged-emacs-devel@m.gmane-mx.org; Thu, 24 Mar 2022 06:22:42 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:60354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXKbI-0003ZT-4r for emacs-devel@gnu.org; Thu, 24 Mar 2022 06:21:52 -0400 Original-Received: from sonic317-34.consmr.mail.ne1.yahoo.com ([66.163.184.45]:39656) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nXKbG-0000hn-9N for emacs-devel@gnu.org; Thu, 24 Mar 2022 06:21:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1648117308; bh=UOnkKPjlgorL2vJ4zRof6JPtS4Ls9s22RunQpyG6/hQ=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=rx9i8GBYptLfHFhDfrBiI8BlzG3xFwZViVUIHb7cNoSJdXDq32NdmRDlCy+w4204Iew7TjJxndlvl1zwUQfNd1ysclDjLHpPGecu7t2+0ONFbGpd6K3vLcnK6m1OmMy6T1OjWtpaOpjtekFeku8rKVUYvWH2Qd37rQ95E0HCKuUNOF2Ktr6IyoQdMJRMM3RjpXsf8kwc1dGPhUaXS/Lsri7Z6iA5+TOIv2NWybjdXwcBngLOEe7bCT/tQfecNDLVCV9/fac5FvQcOaXhvsRdpepufEGCKoKHwTu38CuddAl4lEXyQQfKiQU7s6UGxANbyLN4FbMOobz09sY2IULifA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1648117308; bh=0A6hxHrRUdd0x6OBnChPB0b7J1VPIHWhtuNXVdlwWte=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=e4m/U3DMYiRgZyf46wa79KrUB2VeZXi/44LrZbW8Fq1bcrw7jBxr8ZDDltRGJraA2M560rlFOMgNpU0fs136LurMU7tGv2ziKWpKZkpsUuiaCreXQSvph7J51CvkXzp3d++d3FrQXS1/Y81Qnbk9myoODjmRlyfVIRICPqAk9jNfNgVSZ9R+MxkM1JFzOAL+PhrMsFOORMNeQbPUPCuBjf3Imm2wx8e0Rly3CsdrzA0sEs6xeu26+7mLfBFeL/yhNC6i7WY6IfTt+vSNoDTUaS6Bfvccc89JrI3W0hiRyjfk5lXQNtalLNB5galCpPcyHPL72QZkgOjiurHPEsKcdA== X-YMail-OSG: 84eHRp0VM1lgoP_UBy_EgDiFZYUNJJY6USdICRhvF8xbMOvSE9UM0Cy30NhWJVx OHsA5kRLO7VytCrny3DCeyqHEOv9l5pS8epg_zFAk.jUb3.7bhcPC2B99hHaVWaGjCxzccHvl662 mS9H6_TItZPA_00bLtI_dTFDRtyCUpRMzh3eKkUxV7g7mGoj3h_i8JZ2kKw5TyVVg9q5L0Csgb_V mxH7HsQuc8zl__6C8vDEelX7RR1lt_T.Xp6BdN7eA9FUrbpE7w8DU8UHq0ErI5XPqmk7Md9tjL1k g05nn.mNL978HA0NfRc75oPBIm4doOBUWvXcxWdHvmP3gN3zNtAiykYXlcKfhtkq3ZBZ7wq6eR3h lScvrm6C.buY2FYDrRgihXfkkjZhCeSJXZDKzWDhx76vvi6j2RsiZB.Qq3TNVC5KbMZkeGZyP499 ZiYhccT.tGwP5sAuaDOJAuoASzfaDbrjsEqjqdUctU_duMgnd0_JlmbN85SWtWVeojhhfZmVMLcz P_drQ9_Uy_gvMot1wAdH90IXfN7NVsnExMDCjNfe5P.GlymnF5AZREztRLElLnzxUMMUFZqs4tKx 7ttWmIXY2ULYigmiKyA8q5xpANIQeAAoyWUGNo90ntjGg0jtTmKRI0VwSuSP9Niv.FnO01mV8UUZ 5I9xlz1JLuQfiVhMnRdWO4faKbG3xJWjol6rhzkX95oeCxWqS2xjbNKUqCLjAmbbg5_DQ9erEczn 3lRSTEpSEpdOs7dpXr1NVAXypArvAsrDwfkMF_PJbeRYoi3KLQSXDiljPMH498ViTvSLlk_NHN2I _.Q_Td97WbubK4y5g81jNLVsrXocAGQmfEWp6CFeF_ X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic317.consmr.mail.ne1.yahoo.com with HTTP; Thu, 24 Mar 2022 10:21:48 +0000 Original-Received: by kubenode516.mail-prod1.omega.sg3.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 58f100c8f3507a0b0ad2a2efc5e08700; Thu, 24 Mar 2022 10:21:45 +0000 (UTC) In-Reply-To: <83v8w3d6cy.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 24 Mar 2022 11:53:17 +0200") X-Mailer: WebService/1.1.19987 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.184.45; envelope-from=luangruo@yahoo.com; helo=sonic317-34.consmr.mail.ne1.yahoo.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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" Xref: news.gmane.io gmane.emacs.devel:287410 Archived-At: Eli Zaretskii writes: > I think we used to block input around function calls that could > allocate memory because our signal handlers, and in particular SIGIO > handler, did non-trivial stuff. Nowadays our signal handlers just set > a flag and return, so I'm not sure this is needed anymore. Especially > when system library malloc is called, which AFAIU is mostly async-safe > nowadays on modern platforms. > > Am I missing something? Unfortunately, most system malloc implementations are still not async-signal safe, but if all that happens is a flag being set, then I don't think calling block_input is required anymore. Which flag is that, and where is it tested? > memory_full means basically that the user should save and exit ASAP. > Is that indeed required when SQLite runs out of memory? Isn't it > enough to just fail the SQLite-related function? That's why I asked the second question: SQLite is supposedly very good at coping with allocation failures, so when the memory allocation fails, it probably means there is really no memory left. > I see no reason to go to our malloc as long as SQLite is not supposed > to be invoked before dumping Emacs. > > I'd like to hear others about these issues, though, as I'm not enough > of an expert on this stuff. Indeed, thanks for clarifying.