Re: Detect double-release of spinlock

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Detect double-release of spinlock
Date: 2024-07-29 17:48:53
Message-ID: 20240729174853.uo5qjqkxlacjg6vv@awork3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Hi,

On 2024-07-29 13:25:22 -0400, Tom Lane wrote:
> Heikki Linnakangas <hlinnaka(at)iki(dot)fi> writes:
> > Yeah I'm not worried about that at all. Also, the assert is made when
> > you have already released the spinlock; you are already out of the
> > critical section.
>
> Not in the patch Andres posted.

Which seems fairly fundamental - once outside of the critical section, we
can't actually assert that the lock isn't acquired, somebody else *validly*
might have acquired it by then.

However, I still don't think it's a problem to assert that the lock is held in
in the unlock "routine". As mentioned before, the spinlock implementation
itself has never followed the "just straight line code" rule that users of
spinlocks are supposed to follow.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2024-07-29 17:56:05 Re: pgsql: Fix double-release of spinlock
Previous Message Andres Freund 2024-07-29 17:46:09 Re: pgsql: Fix double-release of spinlock

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-07-29 17:56:05 Re: pgsql: Fix double-release of spinlock
Previous Message Andres Freund 2024-07-29 17:46:09 Re: pgsql: Fix double-release of spinlock