harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Fursov" <mike.fur...@gmail.com>
Subject Re: [drlvm][jitrino] Problem on the implementation of Method_Table class
Date Mon, 12 Nov 2007 08:03:24 GMT
Daizi Sheng,

First I want to thank you for your help - it's the second time in a
week you've found bugs in JIT code.

This bug does not affect any of 'official' modes we support today, but
must be fixed someday.
Could I ask you to file a JIRA issue with the same description of the
problem as you wrote above.

If you have a patch that fixes the problem, I will be ready to test
and commit it asap.



On Nov 12, 2007 9:11 AM, daizi sheng <daizisheng@gmail.com> wrote:
> my example helloworld class may be misleading because it contains too deep
> recursion.
> to make the problem clear, just replace it with very very simple class
>
> package helloworld;
> public class Main {
>     public static void main(String[] args) {
>     }
> }
>
> this is ok because the parameters is load and processed simply before
> running of the real program, I think
>
> 2007/11/12, daizi sheng <daizisheng@gmail.com>:
>
> >
> > the file is: working_vm\vm\jitrino\src\shared\methodtable.cpp
> >
> > in the implementation of member function *init*, there are some errors
> >
> > 1. parameter default_envvar is declared as a *const char* pointer, but
> > used as normal pointer, here is the code snippet
> >
> > void Method_Table::init(const char *default_envvar, const char
> > *envvarname)
> > {
> > ...
> >     char *envvar = (char*)default_envvar;
> > ...
> >     if (envvar[0] == '"')
> >         envvar ++;
> >     if (envvar[strlen(envvar)-1] == '"')
> >         envvar[strlen(envvar)-1] = '\0';
> > ...
> >
> > the problem is that default_envvar is changed into a normal char pointer
> > and then may be modified by the last statement.
> > the source of this parameter is from the ctor of this class
> >
> > Method_Table::Method_Table(MemoryManager& memManager,
> >                            const char *default_envvar,
> >                            const char *envvarname,
> >                            bool accept_by_default):
> >
> > 2. another problem of the above code snippet is that it does not check the
> > boundary of the string in the last two statements
> >
> > image that if envvar contains only one character "\"", the double quote
> > character, in the last *if* statement,
> > strlen(envvar) will be 0, and strlen(envvar)-1 will be 0xffffffff (for
> > 32-bit pointer) because strlen() return unsigned value normally
> >
> > the following steps is about how to trigger out this error
> >
> > 1). add the following line in the opt.emconf (just under -XX:
> > jit.CS_OPT.arg.optimizer.inline.pipeline=CS_OPT_inliner_pipeline)
> > -XX:jit.CS_OPT.arg.optimizer.inline.skip_methods="
> >
> > 2). prepare a helloworld like this
> > package helloworld;
> > public class Main {
> >     public static int fun()
> >     {
> >         fun();
> >         return 1;
> >     }
> >     public static void main(String[] args) {
> >         fun();
> >     }
> >
> > }
> >
> > 3). run java.exe like this
> > working_vm\build\deploy\jdk\jre\bin\java.exe
> > -Xem:working_vm\vm\jitrino\config\ia32\opt.emconf  -jar helloworld.jar
> >
> > 4). at least on my machine, the vm launcher will crash, here is the desc.
> > of my machine
> >
> > windows xp professional version 2002 SP2
> > Pentium(R) 4CPU 3.00Ghz
> > 2.99Ghz, 0.99GB of RAM
> >
> > 3. solution for such errors is simple, maybe simple code refactor
> >
> >
>



-- 
Mikhail Fursov

Mime
View raw message