Re: jsonapi: scary new warnings with LTO enabled

Daniel Gustafsson <daniel@yesql.se>

From: Daniel Gustafsson <daniel@yesql.se>
To: Jacob Champion <jacob.champion@enterprisedb.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2025-04-21T18:20:00Z
Lists: pgsql-hackers
> On 21 Apr 2025, at 17:33, Jacob Champion <jacob.champion@enterprisedb.com> wrote:
> 
> On Sat, Apr 19, 2025 at 2:15 PM Daniel Gustafsson <daniel@yesql.se> wrote:
>> Since there is no way to determine if the allocation succeeded from outside of
>> the JSON api it might be better to keep the calloc and explicitly free it?
> 
> I don't think so; pg_parse_json() will error out quickly, so I don't
> see much advantage to the extra code. Raw performance isn't much of a
> concern for the out-of-memory case, IMO.

Sure, but I fear we'll get an endless stream of static analysis reports for the
allocation leaking if we don't free it.

--
Daniel Gustafsson




Commits

  1. Allocate JsonLexContexts on the heap to avoid warnings