Re: [PATCH] BUG #5566: High levels of savepoint nesting trigger stack overflow in AssignTransactionId

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-bugs(at)postgresql(dot)org
Cc: "Hans van Kranenburg" <hans(dot)van(dot)kranenburg(at)mendix(dot)com>
Subject: Re: [PATCH] BUG #5566: High levels of savepoint nesting trigger stack overflow in AssignTransactionId
Date: 2010-07-19 17:50:12
Message-ID: 201007191950.13856.andres@anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Monday 19 July 2010 17:58:06 Andres Freund wrote:
> On Monday 19 July 2010 17:26:25 Hans van Kranenburg wrote:
> > When issuing an update statement in a transaction with ~30800 levels of
> > savepoint nesting, (which is insane, but possible), postgresql segfaults
> > due to a stack overflow in the AssignTransactionId function, which
> > recursively assign transaction ids to parent transactions.
>
> It seems easy enough to throw a check_stack_depth() in there - survives
> make check here.
>
> It would be nice to check this earlier on though - or simply impose a
> artificial limit of nested transactions. I severely doubt that there are
> non- bug situations with a nesting of above 1k (so maybe set the limit to
> 3k).
>
> Thats independent from checking stack depth there though - it sounds
> possible to get there after an already relatively deep stack usage (deeply
> nested functions or such).
A patch doing both is attached. No idea whether 3k is a good limit.

A small testprogramm is also attached.

Andres

Attachment Content-Type Size
0001-Don-t-segfault-upon-too-deeply-nested-subtransaction.patch text/x-patch 2.4 KB
test.py text/x-python 387 bytes

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2010-07-19 17:57:13 Re: BUG #5566: High levels of savepoint nesting trigger stack overflow in AssignTransactionId
Previous Message Andres Freund 2010-07-19 15:58:06 Re: BUG #5566: High levels of savepoint nesting trigger stack overflow in AssignTransactionId