On Sat, 2009-09-05 at 16:06 +0200, Vegard Nossum wrote:
> 2009/9/5 Pekka Enberg <penb...@cs.helsinki.fi>:
> > This fixes the following uninitialized memory access reported by valgrind:
> >
> >  ==24231== Warning: set address range perms: large range 268435456 (defined)
> >  ==24231== Conditional jump or move depends on uninitialised value(s)
> >  ==24231==    at 0x8069173: alloc_stack_frame (stack-slot.c:45)
> >  ==24231==    by 0x8063ACB: compilation_unit_alloc (compilation-unit.c:87)
> >  ==24231==    by 0x8076860: vm_method_prepare_jit (method.c:168)
> >  ==24231==    by 0x806FF12: vm_class_link (class.c:476)
> >  ==24231==    by 0x8070889: classloader_load (classloader.c:359)
> >  ==24231==    by 0x806FA6B: vm_class_link (class.c:322)
> >  ==24231==    by 0x8070889: classloader_load (classloader.c:359)
> >  ==24231==    by 0x806F932: vm_class_link (class.c:275)
> >  ==24231==    by 0x8070889: classloader_load (classloader.c:359)
> >  ==24231==    by 0x806F932: vm_class_link (class.c:275)
> >  ==24231==    by 0x8070889: classloader_load (classloader.c:359)
> >  ==24231==    by 0x806EC84: vm_class_resolve_class (class.c:734)
> >
> > Cc: Tomek Grabiec <tgrab...@gmail.com>
> > Cc: Vegard Nossum <vegard.nos...@gmail.com>
> > Signed-off-by: Pekka Enberg <penb...@cs.helsinki.fi>
> > ---
> >  vm/class.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/vm/class.c b/vm/class.c
> > index f53f112..7fbee09 100644
> > --- a/vm/class.c
> > +++ b/vm/class.c
> > @@ -442,7 +442,7 @@ int vm_class_link(struct vm_class *vmc, const struct 
> > cafebabe_class *class)
> >
> >        vmc->nr_methods = class->methods_count + extra_methods.size;
> >
> > -       vmc->methods = malloc(sizeof(*vmc->methods) * vmc->nr_methods);
> > +       vmc->methods = calloc(vmc->nr_methods, sizeof(*vmc->methods));
> >        if (!vmc->methods) {
> >                NOT_IMPLEMENTED;
> >                return -1;
> 
> 
> Um, wait, what's the actual dereference that causes the valgrind
> warning? Because as it stands, it looks like you're fixing just the
> symptom and not the real error. We have method initializers that
> should take care of initializing everything, field by field. I'd think
> that's where you'd fix it.

As you can see in the valgrind trace, the problem comes from:

  cu->stack_frame = alloc_stack_frame(
                        method->args_count,
                        method->code_attribute.max_locals);

which means ->code_attribute.max_locals is not initialized. Looking at
cafebabe, I don't see any guarantees that everything will be
initialized.

                        Pekka


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to