I wrote:
> (I seem to recall seeing a similar report once before, but I can't find
> it in the archives right now.)
I found what I think is the bug I was remembering:
http://archives.postgresql.org/pgsql-bugs/2007-05/msg00074.php
but unfortunately it's not much help since we never did resolve
what was happening.
Can you reproduce the problem in a debug-enabled build? It would
be worth stepping through the code to see where it's losing track
of the error message.
regards, tom lane