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@svana.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.