[haiku-development] Question on the arch_cpu_user_memcpy function

  • From: David McPaul <dlmcpaul@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Fri, 2 Oct 2009 11:06:57 +1000

Hello,

I am tracing through an issue I am having when using the profile tool
to profile media add-ons

I get a General Protection Fault code 0x0 in the arch_cpu_user_memcpy
function when the profiler is trying to get the frame stack details

The registers printed in the error stack trace show that the src ptr is NULL

My reading of the code suggests that the error should be trapped and
-1 returned by the function.

Am I wrong here, does the fault handler added not handle a null pointer?

FUNCTION(arch_cpu_user_memcpy):
        pushl   %esi
        pushl   %edi
        movl    12(%esp),%edi   /* dest */
        movl    16(%esp),%esi   /* source */
        movl    20(%esp),%ecx   /* count */

        /* set the fault handler */
        movl    24(%esp),%edx   /* fault handler */
        movl    (%edx),%eax
        movl    $.L_user_memcpy_error, (%edx)

        /* move by words */
        cld
        shrl    $2,%ecx
        rep
        movsl

        /* move any remaining data by bytes */
        movl    20(%esp),%ecx
        andl    $3,%ecx
        rep
        movsb

        /* restore the old fault handler */
        movl    %eax,(%edx)
        xor             %eax,%eax

        popl    %edi
        popl    %esi
        ret

        /* error condition */
.L_user_memcpy_error:
        /* restore the old fault handler */
        movl    %eax,(%edx)
        movl    $-1,%eax        /* return a generic error, the wrapper routine 
will
deal with it */
        popl    %edi
        popl    %esi
        ret
FUNCTION_END(arch_cpu_user_memcpy)


-- 
Cheers
David

Other related posts: