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:22:28 +0800 Message-ID: <87r16rabvf.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="20033"; 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:24:03 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 1nXKdO-00055h-Cn for ged-emacs-devel@m.gmane-mx.org; Thu, 24 Mar 2022 11:24:02 +0100 Original-Received: from localhost ([::1]:59162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nXKdN-0005lZ-5i for ged-emacs-devel@m.gmane-mx.org; Thu, 24 Mar 2022 06:24:01 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:60700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXKc6-0004P7-MM for emacs-devel@gnu.org; Thu, 24 Mar 2022 06:22:42 -0400 Original-Received: from sonic309-20.consmr.mail.ne1.yahoo.com ([66.163.184.146]:45003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nXKc4-0000tf-SW for emacs-devel@gnu.org; Thu, 24 Mar 2022 06:22:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1648117359; bh=UOnkKPjlgorL2vJ4zRof6JPtS4Ls9s22RunQpyG6/hQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=WjQLuapjAtHGN7A5tWmJFptWVXRe4/5VG0LbBgkUF6m7Ua8t3MhyOHIgF9GtmBiCMcqOfJiKFUYa0q/TlvhimUSq3IN7v3Q6kIam2myd2IbT6ECquBwUDoWZiBBA7MVJxswnBkwCCRGUNFH3kWiqxqVna4932GCQDQcmmq49RdLL/kXw36Kugu8GV9Q8aXVBeSOXoh+409Uy0T3nENZXdugWIP4OlyJwM/2CXnsrjLy+hWkqigWCnEAs4IMkeX4c6D0V98njkIDon0NoglpPjkWwq94lk3Ijfo7Pq6JWhmlua8oPkZ/HvPZauspCRxbHSRbBcL/IHR8FdSVmCBfbmQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1648117359; bh=33lAiiaPIw77xHCqmxFmfwlclTztMOkTNWiHGbFEB7n=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=sid4eVmN8dvaPx26VDRPZs00DR3B1z/d58etZIfZyzwKMNGOfdZqnWl0dLiHFkOb4ys+PWUem19fD86rKP6tWykMOpoyYwIJfNcVYxMsxMPF8zqX0g5Q8LYfNXheHoijbxzjZnGIEuT5sOixKbVie9WPOq4xqAFDgUbPZZH43CPfoOsgrujvR3TnLAqKiGo0zh7XDIhcTRP45sFryK5+tExMy3kg9NP8UDoJ/oXSiePyknMWrP0HVTg0jGjHrRheeumgeZU7hu8G/TLh3xzo2LG3t0fVJBfVZSMRJy/w/c/VW9C/4rsGra20hqJK93n2EvMitEcneLRe7QzSsqFslg== X-YMail-OSG: Ym6H6usVM1nlfaW0cy58I4ibgt1eFDVKRGkmCLdJ2hzg9aaOlCPRpWnJm3sUtc6 OyyiRIqa_zZY7.m1aG7d8kixBlqR52CpKR.0UHJyCaX1cFQgrXZw6WK4O3AlNCog1n5xHL.mOa.e lloGXFwJgMbK7S2MJFeMPGDZydKTOdtnXXaZB3hJrsi45NmbODpgs9QtgnAQeHrsfCABYs1p8xoF PL00HqaIvJ.o0aOBf3ZvRnQ8xr35cftenPtmYNHYZ4.dxUOuh.yKbDlNIdgeW6ASdg6fgjxi3DeV kKbSQhhjdV8G.Am9TVyrddq7p.qjqCQJSxWTMSx2PGTRc3afb36SY5souIvXjjuUAMGg4ZH9XnNR kghKytKjpr9c4TX2FNToVLROjWUrz2NY42ws0NkIA4RVgsKZEC_1Z8FB5tGA.QnBHi8wk0KQeCi0 1UIdsZjYNng9PMka6nNvfu74t3XPNWWVY_29.rVgiEXb6Jwqw4XXjMfoXYD5Lm9G6.z3mB58z_C9 _MVYdnT1z3q256a4xY8No_fEvSYrGJ4SLrZHLDC4h6wYhHHT4lPdxJrjcl8MPxhJbMKdwZfjqfoT WN3o3tbTW0wEL6DvScYiHkSzWHFYRz9DNXf1NU1fu67EcjUG2ecwuqrEh3BFdbWRi2_v.GbYZq0H 78OMp5CMqvqfoimDi9Di0UQW0uaYr9ch96L.3.REpE862AjEI6jXIlbvKKAB7uZ2yH4bhM5VXUG2 rzHmwqXBJpkkDJT7OravPSsSUfRH1UkG3nilZVnvcr2dM_btNxJsr8K_oULQYpQ_FQykEnnHbBax Boo2lYrjIA3FxD5IEQSuIJ6IRPJczm8_RU1POLMrQC X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.ne1.yahoo.com with HTTP; Thu, 24 Mar 2022 10:22:39 +0000 Original-Received: by kubenode516.mail-prod1.omega.sg3.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 4a03033b7606e6c8e171c5103536d52f; Thu, 24 Mar 2022 10:22:32 +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.146; envelope-from=luangruo@yahoo.com; helo=sonic309-20.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=unavailable 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:287411 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.