Re: [HACKERS] Win32 WEXITSTATUS too

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Takayuki Tsunakawa <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
Subject: Re: [HACKERS] Win32 WEXITSTATUS too
Date: 2007-01-23 15:40:33
Message-ID: 20070123154033.GB16309@svr2.hagander.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

On Tue, Jan 23, 2007 at 10:32:58AM -0500, Bruce Momjian wrote:
> Takayuki Tsunakawa wrote:
> > From: "Magnus Hagander" <magnus(at)hagander(dot)net>
> > > Are you entirely sure that ntstatus.h is where to look? Because per
> > > whatever docs I've found, that contains "device driver errors" and
> > *not*
> > > exception codes.
> >
> > Yes, what you are pointing out is correct. winbase.h and winnt.h
> > should be consulted instead of ntstatus.h. See the the section
> > "Return Value" in the following page:
> >
> > http://msdn2.microsoft.com/ru-ru/library/ms679356.aspx
>
> Well, it seems to be in two place. I see at:
>
> http://www.microsoft.com/msj/0197/exception/exception.aspx
>
> The ExceptionCode parameter is the number that the operating system
> assigned to the exception. You can see a list of various exception codes
> in WINNT.H by searching for #defines that start with "STATUS_". For
> example, the code for the all-too-familiar STATUS_ACCESS_VIOLATION is
> 0xC0000005. A more complete set of exception codes can be found in
> NTSTATUS.H from the Windows NT DDK.

Actually, that's the first reference so far to say that a kernel level
error code is the same as a userspace exception code. If it is, then
it's safe to use as such. MSJ is generall a very good reference for
these things, even though it's nto an actual documentation.

> > Furthermore, the message is meaningless for users because they can do
> > nothing with the information. So, I think the message should say
> > something like
> >
> > child process was terminated by exception %X
> > This seems to be a bug of PostgreSQL.
> > Please report this message with the details of the phynomenon to
> > PostgreSQL developers.
>
> I am hoping some of the hex values will have descriptions that will help
> users solve problems in their operating system configuration, rather
> than asking us. If they are in a crisis, asking the community might
> not be quick enough.
>
> FYI, here is a patch that recommends ntstatus.h:
>
> http://blog.opsan.com/archive/2005/05/05/447.aspx
> http://www.osronline.com/article.cfm?article=207

This second one is referring to DDK again. The first one doesn't refer
to what it's looking up at all :-(

> This says you can get text for exceptions, but it didn't work for me,
> but I didn't try loading ntdll.dll:
>
> http://support.microsoft.com/kb/259693

Loading ntdll.dll lets you see Kernel mode API errors. If these are
indeed the same as userspace exceptions, then you can load ntdll to get
those. If you don't load ntdll, you can only look at "normal errors".

//Magnus

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2007-01-23 15:40:40 Re: [HACKERS] Win32 WEXITSTATUS too
Previous Message Tom Lane 2007-01-23 15:39:25 Re: Updateable cursors

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2007-01-23 15:40:40 Re: [HACKERS] Win32 WEXITSTATUS too
Previous Message Bruce Momjian 2007-01-23 15:34:57 Re: [HACKERS] Win32 WEXITSTATUS too