Hi,
Here's a patch to fix a EFAULT error returned by ptrace calls in server/context_i386.c, causing tons of "file_set_error: Bad address" errors.
Two arguments to ptrace were reversed.
This is tested on FreeBSD and checked with NetBSD and Solaris ptrace(2) manual pages.
--- wine-20020804.orig/server/context_i386.c Sun Mar 10 01:18:36 2002 +++ wine-20020804/server/context_i386.c Sat Aug 10 19:07:31 2002 @@ -224,7 +224,7 @@ if (flags & CONTEXT_FULL) { struct regs regs; - if (ptrace( PTRACE_GETREGS, pid, 0, (int) ®s ) == -1) goto error; + if (ptrace( PTRACE_GETREGS, pid, (int) ®s, 0 ) == -1) goto error; if (flags & CONTEXT_INTEGER) { context->Eax = regs.r_eax; @@ -259,7 +259,7 @@ { /* we can use context->FloatSave directly as it is using the */ /* correct structure (the same as fsave/frstor) */ - if (ptrace( PTRACE_GETFPREGS, pid, 0, (int) &context->FloatSave ) == -1) goto error; + if (ptrace( PTRACE_GETFPREGS, pid, (int) &context->FloatSave, 0 ) == -1) goto error; context->FloatSave.Cr0NpxState = 0; /* FIXME */ } return; @@ -332,7 +332,7 @@ if (flags & CONTEXT_FULL) { struct reg regs; - if (ptrace( PTRACE_GETREGS, pid, 0, (int) ®s ) == -1) goto error; + if (ptrace( PTRACE_GETREGS, pid, (caddr_t) ®s, 0 ) == -1) goto error; if (flags & CONTEXT_INTEGER) { context->Eax = regs.r_eax; @@ -367,7 +367,7 @@ { /* we can use context->FloatSave directly as it is using the */ /* correct structure (the same as fsave/frstor) */ - if (ptrace( PTRACE_GETFPREGS, pid, 0, (int) &context->FloatSave ) == -1) goto error; + if (ptrace( PTRACE_GETFPREGS, pid, (caddr_t) &context->FloatSave, 0 ) == -1) goto error; context->FloatSave.Cr0NpxState = 0; /* FIXME */ } return; @@ -423,7 +423,7 @@ { /* we can use context->FloatSave directly as it is using the */ /* correct structure (the same as fsave/frstor) */ - if (ptrace( PTRACE_SETFPREGS, pid, 0, (int) &context->FloatSave ) == -1) goto error; + if (ptrace( PTRACE_SETFPREGS, pid, (caddr_t) &context->FloatSave, 0 ) == -1) goto error; } return; error:
On Sat, Aug 10, 2002 at 07:12:07PM +0200, Pierre Beyssac wrote:
Here's a patch to fix a EFAULT error returned by ptrace calls in server/context_i386.c, causing tons of "file_set_error: Bad address" errors.
Please disregard my previous patch, I missed two ptrace occurences. Here's a revised patch.
--- wine-20020804.orig/server/context_i386.c Sun Mar 10 01:18:36 2002 +++ wine-20020804/server/context_i386.c Sat Aug 10 19:22:07 2002 @@ -224,7 +224,7 @@ if (flags & CONTEXT_FULL) { struct regs regs; - if (ptrace( PTRACE_GETREGS, pid, 0, (int) ®s ) == -1) goto error; + if (ptrace( PTRACE_GETREGS, pid, (int) ®s, 0 ) == -1) goto error; if (flags & CONTEXT_INTEGER) { context->Eax = regs.r_eax; @@ -259,7 +259,7 @@ { /* we can use context->FloatSave directly as it is using the */ /* correct structure (the same as fsave/frstor) */ - if (ptrace( PTRACE_GETFPREGS, pid, 0, (int) &context->FloatSave ) == -1) goto error; + if (ptrace( PTRACE_GETFPREGS, pid, (int) &context->FloatSave, 0 ) == -1) goto error; context->FloatSave.Cr0NpxState = 0; /* FIXME */ } return; @@ -278,7 +278,7 @@ if (((flags | CONTEXT_i386) & CONTEXT_FULL) != CONTEXT_FULL) { /* need to preserve some registers */ - if (ptrace( PTRACE_GETREGS, pid, 0, (int) ®s ) == -1) goto error; + if (ptrace( PTRACE_GETREGS, pid, (int) ®s, 0 ) == -1) goto error; } if (flags & CONTEXT_INTEGER) { @@ -305,7 +305,7 @@ regs.r_fs = context->SegFs; regs.r_gs = context->SegGs; } - if (ptrace( PTRACE_SETREGS, pid, 0, (int) ®s ) == -1) goto error; + if (ptrace( PTRACE_SETREGS, pid, (int) ®s, 0 ) == -1) goto error; } if (flags & CONTEXT_DEBUG_REGISTERS) { @@ -315,7 +315,7 @@ { /* we can use context->FloatSave directly as it is using the */ /* correct structure (the same as fsave/frstor) */ - if (ptrace( PTRACE_SETFPREGS, pid, 0, (int) &context->FloatSave ) == -1) goto error; + if (ptrace( PTRACE_SETFPREGS, pid, (int) &context->FloatSave, 0 ) == -1) goto error; } return; error: @@ -332,7 +332,7 @@ if (flags & CONTEXT_FULL) { struct reg regs; - if (ptrace( PTRACE_GETREGS, pid, 0, (int) ®s ) == -1) goto error; + if (ptrace( PTRACE_GETREGS, pid, (caddr_t) ®s, 0 ) == -1) goto error; if (flags & CONTEXT_INTEGER) { context->Eax = regs.r_eax; @@ -367,7 +367,7 @@ { /* we can use context->FloatSave directly as it is using the */ /* correct structure (the same as fsave/frstor) */ - if (ptrace( PTRACE_GETFPREGS, pid, 0, (int) &context->FloatSave ) == -1) goto error; + if (ptrace( PTRACE_GETFPREGS, pid, (caddr_t) &context->FloatSave, 0 ) == -1) goto error; context->FloatSave.Cr0NpxState = 0; /* FIXME */ } return; @@ -386,7 +386,7 @@ if (((flags | CONTEXT_i386) & CONTEXT_FULL) != CONTEXT_FULL) { /* need to preserve some registers */ - if (ptrace( PTRACE_GETREGS, pid, 0, (int) ®s ) == -1) goto error; + if (ptrace( PTRACE_GETREGS, pid, (caddr_t) ®s, 0 ) == -1) goto error; } if (flags & CONTEXT_INTEGER) { @@ -413,7 +413,7 @@ regs.r_fs = context->SegFs; regs.r_gs = context->SegGs; } - if (ptrace( PTRACE_SETREGS, pid, 0, (int) ®s ) == -1) goto error; + if (ptrace( PTRACE_SETREGS, pid, (caddr_t) ®s, 0 ) == -1) goto error; } if (flags & CONTEXT_DEBUG_REGISTERS) { @@ -423,7 +423,7 @@ { /* we can use context->FloatSave directly as it is using the */ /* correct structure (the same as fsave/frstor) */ - if (ptrace( PTRACE_SETFPREGS, pid, 0, (int) &context->FloatSave ) == -1) goto error; + if (ptrace( PTRACE_SETFPREGS, pid, (caddr_t) &context->FloatSave, 0 ) == -1) goto error; } return; error:
Pierre Beyssac wrote:
On Sat, Aug 10, 2002 at 07:12:07PM +0200, Pierre Beyssac wrote:
Here's a patch to fix a EFAULT error returned by ptrace calls in server/context_i386.c, causing tons of "file_set_error: Bad address" errors.
Please disregard my previous patch, I missed two ptrace occurences. Here's a revised patch.
Patches that you want to submit to wine should be addressed to wine-patches@winehq.com or wine-patches@winehq.org. Patches that are sent to wine -devel are generally for discussion purposes only and not meant to be applied to CVS. If you are unsure that you have done things the right way and want some feedback but are reasonably confident that the patch is correct you can always CC wine devel.
Tony Lambregts
PS: I applied your patch and it does not seem to break any of my test apps using RedHat 7.2 (Linux)
Tony Lambregts