Re: stack depth limit exceeded problem.

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Thomas Hallgren <thhal(at)mailblocks(dot)com>
Cc: Oliver Jowett <oliver(at)opencloud(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: stack depth limit exceeded problem.
Date: 2005-09-24 13:54:11
Message-ID: 20050924135406.GC25542@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Sep 24, 2005 at 02:38:35PM +0200, Thomas Hallgren wrote:
> Martijn van Oosterhout wrote:
> > Linux has sigaltstack so you can catch the stack overflow signal (and
> > other signals obviously, but that's its main use), but it's not terribly
> > portable.
> >
> I rely on the signal handler that the JVM uses for page-faults (which a
> stack overflow generally amounts to) and fpe exeptions so I know that
> they will generate java exceptions in a controlled way (which I in turn
> translate to elog(ERROR) on the main thread).

Well, actually, what I was thinking is if someone sends a -INT or -TERM
to the backend, which thread will catch it? You have to block it in
every thread except the one you want to catch it in if you want to
control it. This means that for any signal handler that PostgreSQL
installs, you need to intercept it with a wrapper function to make sure
it runs in the right stack.

Actually, while running backend code, you're probably fine since the
elog stuff will handle it. But if a signal is received while the JVM is
running, the signal handler will get the stack of the JVM. Now,
PostgreSQLs signal handlers tend not to do much so you may be safe.
They tend not to throws errors, but who knows...

Still, this is all solvable I think...
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-09-24 15:20:38 Re: 64-bit API for large objects
Previous Message Thomas Hallgren 2005-09-24 12:38:35 Re: stack depth limit exceeded problem.