Re: terminate called after throwing an instance of 'std::bad_alloc' - Mailing list pgsql-hackers

From Andres Freund
Subject Re: terminate called after throwing an instance of 'std::bad_alloc'
Date
Msg-id 20210419164130.byegpfrw46mzagcu@alap3.anarazel.de
Whole thread Raw
In response to Re: terminate called after throwing an instance of 'std::bad_alloc'  (Justin Pryzby <pryzby@telsasoft.com>)
Responses Re: terminate called after throwing an instance of 'std::bad_alloc'  (Justin Pryzby <pryzby@telsasoft.com>)
Re: terminate called after throwing an instance of 'std::bad_alloc'  (Justin Pryzby <pryzby@telsasoft.com>)
List pgsql-hackers
Hi,

On 2021-04-17 19:13:24 -0500, Justin Pryzby wrote:
> I'm now realizing that that's RAM use for a single query, not from continuous
> leaks across multiple queries.

What's the memory usage with inlining disabled, and whats the usage
without jit?


> This is still true with the patch even if I
> #define LLVMJIT_LLVM_CONTEXT_REUSE_MAX 1
>
>   PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
> 28438 postgres  20   0 3854264   2.8g  29428 R  98.7 33.2   8:56.79 postgres: telsasoft ts 192.168.122.11(53614)
BIND
>
> python3 ./jitleak.py # runs telsasoft reports
> INFO:  recreating LLVM context after 2 uses
> INFO:  recreating LLVM context after 2 uses
> INFO:  recreating LLVM context after 2 uses
> INFO:  recreating LLVM context after 2 uses
> INFO:  recreating LLVM context after 2 uses
> PID 27742 finished running report; est=None rows=40745; cols=34; ... duration:538
> INFO:  recreating LLVM context after 81492 uses
>
> I did:
>
> -               llvm_llvm_context_reuse_count = 0;
>                 Assert(llvm_context != NULL);
> +               elog(INFO, "recreating LLVM context after %zu uses", llvm_llvm_context_reuse_count);
> +               llvm_llvm_context_reuse_count = 0;
>
> Maybe we're missing this condition somehow ?
>         if (llvm_jit_context_in_use_count == 0 &&

Do you utilize cursors or such?


> Also, I just hit this assertion by cancelling the query with ^C / sigint.  But
> I don't have a reprodcer for it.
>
> < 2021-04-17 19:14:23.509 ADT telsasoft >PANIC:  LLVMJitContext in use count not 0 at exit (is 1)

Hm, I'll try to see how that happens - if not, do you have a backtrace?

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Mark Dilger
Date:
Subject: Re: pg_amcheck option to install extension
Next
From: Robert Haas
Date:
Subject: Re: Commit 86dc90056 - Rework planning and execution of UPDATE and DELETE