[PATCH] winedbg: Avoid truncating a 32 bit exception code as exit code

Martin Storsjö martin at martin.st
Mon May 13 04:08:03 CDT 2019


On Fri, 10 May 2019, Ken Thomases wrote:

> On May 10, 2019, at 3:20 PM, Martin Storsjo <martin at martin.st> wrote:
>>
>> On unix, traditionally only the lower 8 bits of the exit code
>> are returned. In case ExceptionCode is EXCEPTION_WINE_STUB,
>> 80000100, the observed exit code outside is zero, which would
>> indicate successful execution.
>>
>> Therefore, just return a one, instead of trying to pass on the
>> whole exception code, of which only a quarter is returned on unix.
>>
>> Signed-off-by: Martin Storsjo <martin at martin.st>
>> ---
>> programs/winedbg/tgt_active.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c
>> index 5385d0effa..0a4453f8d6 100644
>> --- a/programs/winedbg/tgt_active.c
>> +++ b/programs/winedbg/tgt_active.c
>> @@ -977,7 +977,7 @@ static BOOL tgt_process_active_close_process(struct dbg_process* pcs, BOOL kill)
>>         DWORD exit_code = 0;
>>
>>         if (pcs == dbg_curr_process && dbg_curr_thread->in_exception)
>> -            exit_code = dbg_curr_thread->excpt_record.ExceptionCode;
>> +            exit_code = 1;
>>
>>         TerminateProcess(pcs->handle, exit_code);
>>     }
>
> Other Win32 programs could presumably get the full exit code passed to TerminateProcess(), right?

I guess so, yes.

> This seems like a problem that should be fixed at the point of the call 
> to exit() or _exit(), instead.

Hmm...

Would the generic exiting logic then be to return the lower 8 
bits of the return code, unless the full value is nonzero but the lower 8 
bits are zero, when we instead would return just 1? Is that something that 
is generic enough to apply for any process?

// Martin




More information about the wine-devel mailing list