Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rgVVS-006Rh2-3H for pgsql-bugs@arkaria.postgresql.org; Sat, 02 Mar 2024 19:58:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rgVVP-00Gwnl-UP for pgsql-bugs@arkaria.postgresql.org; Sat, 02 Mar 2024 19:58:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rgVVP-00Gwmx-MT for pgsql-bugs@lists.postgresql.org; Sat, 02 Mar 2024 19:58:48 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rgVVI-002X31-Ob for pgsql-bugs@lists.postgresql.org; Sat, 02 Mar 2024 19:58:46 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 422JwdQ43148163; Sat, 2 Mar 2024 14:58:39 -0500 From: Tom Lane To: Alexander Lakhin cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18374: Printing memory contexts on OOM condition might lead to segmentation fault In-reply-to: <3140126.1709405398@sss.pgh.pa.us> References: <18374-ebb8113ce4d02f0d@postgresql.org> <3120721.1709395887@sss.pgh.pa.us> <3140126.1709405398@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sat, 02 Mar 2024 13:49:58 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3148161.1709409519.1@sss.pgh.pa.us> Date: Sat, 02 Mar 2024 14:58:39 -0500 Message-ID: <3148162.1709409519@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > I think what must be happening is that the kernel is refusing > to expand our stack any more once we've hit the "ulimit -v" limit. > This is quite nasty, because it breaks all our assumptions about > having X amount of stack still available once check_stack_depth > triggers. I find this in [1]: The C language stack growth does an implicit mremap. If you want absolute guarantees and run close to the edge you MUST mmap your stack for the largest size you think you will need. For typical stack usage this does not matter much but it's a corner case if you really really care Seems like we need to do some more work at startup to enforce that we have the amount of stack we think we do, if we're on Linux. regards, tom lane [1] https://www.kernel.org/doc/Documentation/vm/overcommit-accounting