dotgnu-libjit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Dotgnu-libjit] How Do I Debug a Memory Protection Error?


From: Noah Lavine
Subject: Re: [Dotgnu-libjit] How Do I Debug a Memory Protection Error?
Date: Mon, 18 Oct 2010 23:35:56 -0400

Hello,

I have found the following test case, which is a 63-line program which
gives a bus error on my machine.

As expected, GDB shows a kernel protection failure at address
0x00000001001004e0, which also happens to be the value of the
"function" variable, and in register 11.

Here is the test program.

#include <stdio.h>
#include <jit/jit.h>

enum jit_return_t {
  jit_return_return = 0,
  jit_return_wrong_num_args
};

static jit_context_t context = (jit_context_t) NULL;
static jit_type_t signature = NULL;

int main(int argc, char *argv[])
{
  jit_type_t ip_type, sp_type, fp_type, params[3], ret_type;
  jit_function_t function;
  jit_value_t ipp, spp, fpp, ip, sp, fp, ipup, spup;

  jit_init();
  context = jit_context_create();

  ip_type = jit_type_create_pointer
    (jit_type_create_pointer (jit_type_ubyte, 0),
     1);
  sp_type = jit_type_create_pointer
    (jit_type_create_pointer (jit_type_void_ptr, 0),
     1);
  fp_type = sp_type;

  params[0] = ip_type;
  params[1] = sp_type;
  params[2] = fp_type;

  ret_type = jit_type_ubyte;

  signature = jit_type_create_signature
    (jit_abi_cdecl, /* native C calling conventions */
     ret_type,
     params,
     3, /* there are 3 params */
     1); /* yes, increment the reference counts for the types we use */

  jit_context_build_start(context);

  function = jit_function_create(context, signature);

  jit_insn_return(function,
                  jit_value_create_nint_constant(function,
jit_type_int, jit_return_return));

  jit_function_compile(function);

  jit_context_build_end(context);

  {
    enum jit_return_t retval;
    int argvals[] = {3, 4, 5};
    void *args[] = {&(argvals[0]), &(argvals[1]), &(argvals[2])};

    jit_apply(signature, function, args, 3, &retval);
  }

  printf("Completed without bus error!\n");
}

Thanks a lot for your help!
Noah

On Mon, Oct 18, 2010 at 6:05 PM, Noah Lavine <address@hidden> wrote:
>> Do you use on demand compilation in your program?
>
> No, I call jit_function_compile on it immediately after generating it.
>
> I will see if I can get a simpler test program to exhibit the same
> behavior, to make this easier.
>
> Noah
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]