Re: PL/Python: Fix return in the middle of PG_TRY() block. - Mailing list pgsql-hackers

From Andres Freund
Subject Re: PL/Python: Fix return in the middle of PG_TRY() block.
Date
Msg-id 20230113072346.ruaiubf4douhmi4i@awork3.anarazel.de
Whole thread Raw
In response to Re: PL/Python: Fix return in the middle of PG_TRY() block.  (Andres Freund <andres@anarazel.de>)
Responses Re: PL/Python: Fix return in the middle of PG_TRY() block.
List pgsql-hackers
Hi,

On 2023-01-12 21:49:00 -0800, Andres Freund wrote:
> Clearly this would need a bunch more work, but it seems promising? I think
> there'd be other uses than this.
> 
> I briefly tried to use it for spinlocks. Mostly works and detects things like
> returning with a spinlock held. But it does not like dynahash's habit of
> conditionally acquiring and releasing spinlocks.

One example is to prevent things like elog()/ereport()/SpinlockAcquire() while
holding a spinlock

The "locks_excluded(thing)" attribute (which is just heuristic, doesn't require
expansive annotation like requires_capability(!thing)), can quite easily be
used to trigger warnings about this kind of thing:

../../../../home/andres/src/postgresql/src/backend/access/transam/xlog.c:6771:2: warning: cannot call function
'errstart'while no_nested_spinlock 'in_spinlock' is held [-Wthread-safety-analysis]
 
        elog(LOG, "logging with spinlock held");


Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: allowing for control over SET ROLE
Next
From: Jeff Davis
Date:
Subject: Re: Blocking execution of SECURITY INVOKER