2009/7/20 Vegard Nossum <vegard.nos...@gmail.com>:
> We cannot rely on arrays and fields to be smaller than a page in size
> for this test to work, i.e.
>
>        byte[] a = null;
>        a[4096] = ...;
>
> must still throw NullPointerException.
>
> Signed-off-by: Vegard Nossum <vegard.nos...@gmail.com>
> ---
>  include/vm/object.h |    7 ++++++-
>  vm/signal.c         |    2 +-
>  2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/include/vm/object.h b/include/vm/object.h
> index 9bb4b93..864f7c3 100644
> --- a/include/vm/object.h
> +++ b/include/vm/object.h
> @@ -13,7 +13,10 @@ enum vm_type;
>
>  struct vm_object {
>        /* For arrays, this points to the array type, e.g. for int arrays,
> -        * this points to the (artificial) class named "[I". */
> +        * this points to the (artificial) class named "[I". We actually rely
> +        * on this being the first field in the struct, because this way we
> +        * don't need a null-pointer check for accessing this object whenever
> +        * we access ->class first. */
>        struct vm_class *class;
>
>        pthread_mutex_t mutex;
> @@ -22,6 +25,8 @@ struct vm_object {
>        uint8_t fields[];
>  };
>
> +/* XXX: BUILD_BUG_ON(offsetof(vm_object, class) != 0); */
> +
>  int init_vm_objects(void);
>
>  struct vm_object *vm_object_alloc(struct vm_class *class);
> diff --git a/vm/signal.c b/vm/signal.c
> index da2b6d4..cba8460 100644
> --- a/vm/signal.c
> +++ b/vm/signal.c
> @@ -98,7 +98,7 @@ static void sigsegv_handler(int sig, siginfo_t *si, void 
> *ctx)
>
>        /* Assume that zero-page access is caused by dereferencing a
>           null pointer */
> -       if ((unsigned long)si->si_addr < (unsigned long)getpagesize()) {
> +       if (!si->si_addr) {
>                /* We must be extra caucious here because IP might be
>                   invalid */
>                if (get_signal_source_cu(ctx) == NULL)
> --
> 1.6.0.6
>

Acked-by: Tomasz Grabiec <tgrab...@gmail.com>


-- 
Tomek Grabiec

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to