pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Make stack depth check work with asan's use-after-return
Date: Wed, 27 May 2026 09:54:51 -0400
Message-ID: <465155.1779890091@sss.pgh.pa.us> (raw)
In-Reply-To: <2kk4z4odvuyrg7qlwjd7ft4eron4cle4btb33v4qatgsdkayir@gj6e62rgsel4>
References: <2kk4z4odvuyrg7qlwjd7ft4eron4cle4btb33v4qatgsdkayir@gj6e62rgsel4>

Andres Freund <andres@anarazel.de> writes:
> The reason for that breakage is that with the stack-use-after-return logic,
> stack variables are moved to heap allocations, to allow to detect references
> to the memory at a later time. That breaks our stack-depth check, which is why
> we had to disable detect_stack_use_after_return in CI. Luckily
> __builtin_frame_address() works correctly, even under asan, so use that.
> I think we should backpatch this. I'd be worried about using
> __builtin_frame_address(), but we already do, for the base address of the
> stack.

+1.  It was a little weird that we adopted __builtin_frame_address()
to measure the location of the stack bottom but not the stack top.
So I think this is good cleanup even if ASAN weren't forcing it.

I might write the comments a bit differently, in particular I suggest
changing

- 	 * Compute distance from reference point to my local variables
+ 	 * Compute distance from reference point to my stack frame

			regards, tom lane





view thread (3+ messages)  latest in thread

Message-ID: <465155.1779890091@sss.pgh.pa.us>
Permalink:  ../465155.1779890091@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/465155.1779890091@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andres@anarazel.de
  Subject: Re: Make stack depth check work with asan's use-after-return
  In-Reply-To: <465155.1779890091@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox