harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "daizi sheng" <daizish...@gmail.com>
Subject [drlvm][jitrino] Problem on the implementation of Method_Table class
Date Mon, 12 Nov 2007 02:59:46 GMT
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:

2). prepare a helloworld like this
package helloworld;
public class Main {
    public static int fun()
        return 1;
    public static void main(String[] args) {


3). run java.exe like this
-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

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message