Re: CLOBBER_CACHE_ALWAYS regression instability - Mailing list pgsql-hackers

From Andres Freund
Subject Re: CLOBBER_CACHE_ALWAYS regression instability
Date
Msg-id 20200406000715.sf7tnh4og7oncscl@alap3.anarazel.de
Whole thread Raw
In response to Re: CLOBBER_CACHE_ALWAYS regression instability  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers
Hi,

On 2020-04-05 19:54:19 -0400, Alvaro Herrera wrote:
> Isn't it the case that you can create an inner block with a constant
> whose size is determined by a containing block's variable?  I mean as in
> the attached, which refuses to compile because of our -Werror=vla -- but
> if I remove it, it compiles fine and works in my system.

IIRC msvc doesn't support VLAs. And there's generally a slow push
towards deprecating them (they've e.g. been moved to optional in C11).

They don't tend to make a lot of sense for sizes that aren't tightly
bound. In contrast to palloc etc, there's no good way to catch
allocation errors. Most of the time you'll just get a SIGBUS or such,
but sometimes you'll just end up overwriting data (if the allocation is
large enough to not touch the guard pages).

Both alloca/vlas also add some per-call overhead.

Allocating the common size on-stack, and the uncommon ones on heap
should be cheaper, and handles the cases of large allocations much
better.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Grigory Smolkin
Date:
Subject: archive recovery fetching wrong segments
Next
From: Peter Geoghegan
Date:
Subject: Re: nbtree: assertion failure in _bt_killitems() for posting tuple