Re: [HACKERS] Win32 WEXITSTATUS too

From: "Takayuki Tsunakawa" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>
To: "Bruce Momjian" <bruce(at)momjian(dot)us>
Cc: "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>, "Magnus Hagander" <magnus(at)hagander(dot)net>, "ITAGAKI Takahiro" <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
Subject: Re: [HACKERS] Win32 WEXITSTATUS too
Date: 2007-01-23 04:07:06
Message-ID: 029201c73ea3$f221ef10$19527c0a@OPERAO
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

From: "Bruce Momjian" <bruce(at)momjian(dot)us>
Yes, you are 100% correct that I had exceptions and errors confused.
I
> have backed out the patch that used FormatMessage(), and instead of
> using a URL, the message is now:
>
> child process was terminated by exception %X
> See /include/ntstatus.h for a description of the hex value.
>
> When I search for /include/ntstatus.h, I get the Wine page first, so
> hopefully we can mark this item as completed.

Thank you, Bruce-san. I agree.

----- Original Message -----
From: "Bruce Momjian" <bruce(at)momjian(dot)us>
To: "Takayuki Tsunakawa" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>
Cc: "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>;
"Magnus Hagander" <magnus(at)hagander(dot)net>; "ITAGAKI Takahiro"
<itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
Sent: Tuesday, January 23, 2007 12:35 PM
Subject: Re: [pgsql-patches] [HACKERS] Win32 WEXITSTATUS too

> Takayuki Tsunakawa wrote:
>> From: "Bruce Momjian" <bruce(at)momjian(dot)us>
>> > OK, I have tested on MinGW and found I can use FormatMessage() to
>> print
>> > a description for all ERROR* system() failures, rather than print
a
>> hex
>> > value. This removes the need for a URL or lookup of hex values.
>> > Attached and applied.
>>
>> Excuse me if I'm misunderstanding, but I'm afraid you are mixing up
>> Win32 error codes and exception codes. I saw the following
fragment
>> in your patch:
>>
>> ! * On MinGW, system() returns STATUS_* values. MSVC might be
>> ! * different. To test, create a binary that does *(NULL), and
>> ! * then create a second binary that calls it via system(),
>> ! * and check the return value of system(). On MinGW, it is
>> ! * 0xC0000005 == STATUS_ACCESS_VIOLATION, and 0x5 is a value
>> ! * FormatMessage() can look up. GetLastError() does not work;
>> ! * always zero.
>>
>> Exception codes and error codes are different and not related. In
the
>> above test, 0xC0000005 is an "exception code". On the other hand,
what
>> FormatMessage() accepts is an error code. Error codes can't
derived
>> from exception codes. Stripping off 0xC bit from an exception code
>> does not convert it to an error code.
>> I suspect the reason why you misunderstood is that the descriptions
>> are similar:
>> the description for exception 0xC0000005 (STATUS_ACCESS_VIOLATION)
is
>> "access violation" (though the text can't be obtained). This is
>> caused by an illegal memory access. This is a program bug.
>> The description for 0x5 (ERROR_ACCESS_DENIED) is "Access is
denied."
>> This is caused by permission checks. This is not a bug, and can
>> happen normally.
>>
>> Try "1.0 / 0.0" (devide by zero) instead of (*NULL). What would
your
>> patch display? The exception would be 0xC000008E
>> (STATUS_FLOAT_DIVIDE_BY_ZERO), I think. 0x8E is ERROR_BUSY_DRIVE.
>
> Yes, you are 100% correct that I had exceptions and errors confused.
I
> have backed out the patch that used FormatMessage(), and instead of
> using a URL, the message is now:
>
> child process was terminated by exception %X
> See /include/ntstatus.h for a description of the hex value.
>
> When I search for /include/ntstatus.h, I get the Wine page first, so
> hopefully we can mark this item as completed.
>
> --
> Bruce Momjian bruce(at)momjian(dot)us
> EnterpriseDB http://www.enterprisedb.com
>
> + If your life is a hard drive, Christ can be your backup. +
>
> ---------------------------(end of
broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message ITAGAKI Takahiro 2007-01-23 04:10:20 Re: Piggybacking vacuum I/O
Previous Message Bruce Momjian 2007-01-23 03:35:11 Re: [HACKERS] Win32 WEXITSTATUS too

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2007-01-23 05:02:51 Re: [HACKERS] Win32 WEXITSTATUS too
Previous Message Bruce Momjian 2007-01-23 03:35:11 Re: [HACKERS] Win32 WEXITSTATUS too