Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mnops-0000WW-EJ for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Nov 2021 21:20:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mnopq-0002a5-2t for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Nov 2021 21:20:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mnopp-0002Zw-Kq for pgsql-hackers@lists.postgresql.org; Thu, 18 Nov 2021 21:20:45 +0000 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mnopm-0007Y3-Hy for pgsql-hackers@postgresql.org; Thu, 18 Nov 2021 21:20:45 +0000 Received: by mail-io1-xd34.google.com with SMTP id m9so10041336iop.0 for ; Thu, 18 Nov 2021 13:20:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=my0kp5VPWZdeptJ7GJTjs6z+DKgdehSgvPPnSJISKQc=; b=awKXHFpr8QRjr+3AVUp95HCMZDSPmi0HJThv4+vm97F/Sg4iAehJ5176yf4OTp7APQ N/o9J5TLZEJe4DVqPR4qHxTc6iDZx2l/qvBjSSaLrHxFsuVVohMJ7le+C1fO+TuCiUJe inEpiia0dlZRkm3h53DqLLN0OFlJMBBIe1IL5tPhCb4pwsulatTSYiVQl5tJj09RLCxd +jcvk1nLD+tIWPJqUPABVpgY9VB97jfMaeNwJYidX65HGZpnvA7XVTZTg2esh2Y8TcqI NAYHySLOzUssB1gtp3UYS7j/BRI6TuhvpkhCv2R7mGDWNwMquZAx7mDlqb6xh3tNdla1 4H2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=my0kp5VPWZdeptJ7GJTjs6z+DKgdehSgvPPnSJISKQc=; b=Yod62pukkDpEGf28yJhPhIdXTD2uMG6MNDfsEmwKJU85cMNM/6tjXAOGO3QLBiodCk +/RP8mkXz2S70kOkeCw9uaQasChJhA4w9mVWBAqRk3STErlrW1K13JLBD3KgJSxRaujf KWsoeWR2dC5v7Qx17KfLckT9tY8kIl2WeGjrDMUP1ML+K7smfsKuakO2ww0pCuJA0CKj mJnrwLFHR2aeyam3x1C8oRSUGN/s4BszN372eC86mqkMVKxzaSmgQzJa6+FCjlWDzoZn QooY+lvLW48w8kDiU9R6fqQbg+eSZj/khW3FwGzCWiYSMOq/Z9QjnbFBe2y3TlYhc8hf gF1A== X-Gm-Message-State: AOAM5329MHXP/XjGBm7CHNBPRxqoB/iNiZR+JoUkI0bf0/+nKQ9N90r1 EeSX6BYYi3/K23FpX99+qppczw== X-Google-Smtp-Source: ABdhPJyx5yjZeZxWrvJPVuUwQhInP7d3wWDxZWTjD1uecUBfVYbWb4AOO1HS0U9D6Nns668DCrRIBA== X-Received: by 2002:a05:6638:22d6:: with SMTP id j22mr23151063jat.97.1637270440632; Thu, 18 Nov 2021 13:20:40 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id a25sm535595ioa.24.2021.11.18.13.20.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Nov 2021 13:20:40 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 8715C800989; Thu, 18 Nov 2021 15:20:39 -0600 (CST) Date: Thu, 18 Nov 2021 15:20:39 -0600 From: Justin Pryzby To: Andres Freund Cc: pgsql-hackers@postgresql.org, Tom Lane Subject: Re: terminate called after throwing an instance of 'std::bad_alloc' (llvmjit) Message-ID: <20211118212039.GT17618@telsasoft.com> References: <20201001021609.GC8476@telsasoft.com> <20201003220236.GL8476@telsasoft.com> <20201003230149.mtd7fjsjwgii3jv7@alap3.anarazel.de> <20201003233045.GM8476@telsasoft.com> <20201004020127.zbrol2ypu6tg2bei@alap3.anarazel.de> <20201007230242.rnwsbnxywvthef3w@alap3.anarazel.de> <20201218235607.GC30237@telsasoft.com> <20211110155644.GA17618@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211110155644.GA17618@telsasoft.com> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Nov 10, 2021 at 09:56:44AM -0600, Justin Pryzby wrote: > Thread starting here: > https://www.postgresql.org/message-id/20201001021609.GC8476%40telsasoft.com > > On Fri, Dec 18, 2020 at 05:56:07PM -0600, Justin Pryzby wrote: > > I'm 99% sure the "bad_alloc" is from LLVM. It happened multiple times on > > different servers (running a similar report) after setting jit=on during pg13 > > upgrade, and never happened since re-setting jit=off. > > Since this recurred a few times recently (now running pg14.0), and I finally > managed to get a non-truncated corefile... I think the reason this recurred is that, since upgrading to pg14, I no longer had your memleak patches applied. I'd forgotten about it, but was probably running a locally compiled postgres with your patches applied. I should've mentioned that this crash was associated with the message from the original problem report: |terminate called after throwing an instance of 'std::bad_alloc' | what(): std::bad_alloc The leak discussed on other threads seems fixed by your patches - I compiled v14 and now running with no visible leaks since last week. https://www.postgresql.org/message-id/flat/20210417021602.7dilihkdc7oblrf7@alap3.anarazel.de As I understand it, there's still an issue with an allocation failure causing SIGABRT rather than FATAL. It took me several tries to get the corefile since the process is huge, caused by the leak (and abrtd wanted to truncate it, nullifying its utility). -rw-------. 1 postgres postgres 8.4G Nov 10 08:57 /var/lib/pgsql/14/data/core.31345 I installed more debug packages to get a fuller stacktrace. #0 0x00007f2497880337 in raise () from /lib64/libc.so.6 No symbol table info available. #1 0x00007f2497881a28 in abort () from /lib64/libc.so.6 No symbol table info available. #2 0x00007f2487cbf265 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib64/llvm5.0/lib/libLLVM-5.0.so No symbol table info available. #3 0x00007f2487c66696 in __cxxabiv1::__terminate(void (*)()) () from /usr/lib64/llvm5.0/lib/libLLVM-5.0.so No symbol table info available. #4 0x00007f2487c666c3 in std::terminate() () from /usr/lib64/llvm5.0/lib/libLLVM-5.0.so No symbol table info available. #5 0x00007f2487c687d3 in __cxa_throw () from /usr/lib64/llvm5.0/lib/libLLVM-5.0.so No symbol table info available. #6 0x00007f2487c686cd in operator new(unsigned long) () from /usr/lib64/llvm5.0/lib/libLLVM-5.0.so No symbol table info available. #7 0x00007f2486477b9c in allocateBuckets (this=0x2ff7f38, this=0x2ff7f38, Num=) at /usr/src/debug/llvm-5.0.1.src/include/llvm/ADT/DenseMap.h:753 No locals. #8 llvm::DenseMap >, llvm::DenseMapAPIntKeyInfo, llvm::detail::DenseMapPair > > >::grow (this=this@entry=0x2ff7f38, AtLeast=) at /usr/src/debug/llvm-5.0.1.src/include/llvm/ADT/DenseMap.h:691 OldNumBuckets = 33554432 OldBuckets = 0x7f23f3e42010 #9 0x00007f2486477f29 in grow (AtLeast=, this=0x2ff7f38) at /usr/src/debug/llvm-5.0.1.src/include/llvm/ADT/DenseMap.h:461 No locals. #10 InsertIntoBucketImpl (TheBucket=, Lookup=..., Key=..., this=0x2ff7f38) at /usr/src/debug/llvm-5.0.1.src/include/llvm/ADT/DenseMap.h:510 NewNumEntries = EmptyKey = #11 InsertIntoBucket (Key=..., TheBucket=, this=0x2ff7f38) at /usr/src/debug/llvm-5.0.1.src/include/llvm/ADT/DenseMap.h:471 No locals. #12 FindAndConstruct (Key=..., this=0x2ff7f38) at /usr/src/debug/llvm-5.0.1.src/include/llvm/ADT/DenseMap.h:271 TheBucket = #13 operator[] (Key=..., this=0x2ff7f38) at /usr/src/debug/llvm-5.0.1.src/include/llvm/ADT/DenseMap.h:275 No locals. #14 llvm::ConstantInt::get (Context=..., V=...) at /usr/src/debug/llvm-5.0.1.src/lib/IR/Constants.cpp:550 pImpl = 0x2ff7eb0 #15 0x00007f2486478263 in llvm::ConstantInt::get (Ty=0x2ff85a8, V=, isSigned=isSigned@entry=false) at /usr/src/debug/llvm-5.0.1.src/lib/IR/Constants.cpp:571 No locals. #16 0x00007f248648673d in LLVMConstInt (IntTy=, N=, SignExtend=SignExtend@entry=0) at /usr/src/debug/llvm-5.0.1.src/lib/IR/Core.cpp:952 No locals. #17 0x00007f2488f66c18 in l_ptr_const (type=0x3000650, ptr=) at ../../../../src/include/jit/llvmjit_emit.h:29 c = #18 llvm_compile_expr (state=) at llvmjit_expr.c:246 op = 0x1a5317690 opcode = EEOP_OUTER_VAR opno = 5 parent = funcname = 0x1a53184e8 "evalexpr_4827_151" context = 0x1ba79b8 b = mod = 0x1a5513d30 eval_fn = entry = v_state = 0x1a5ce09e0 v_econtext = 0x1a5ce0a08 v_isnullp = 0x1a5ce0a30 v_tmpvaluep = 0x1a5ce0aa8 v_tmpisnullp = 0x1a5ce0b48 starttime = {tv_sec = 10799172, tv_nsec = 781670770} endtime = {tv_sec = 7077194792, tv_nsec = 0} __func__ = "llvm_compile_expr" [...]