Bug in Jitter

Alexandre Oliva oliva at dcc.unicamp.br
Tue Jul 7 15:27:32 PDT 1998


Godmar Back <gback at cs.utah.edu> writes:

>> > I suspect the proper fix would be to ensure that all live
>> > registers are written to memory whenever an exception, including a
>> > null pointer exception, may occur.  

> Tim wrote about it over a year ago:

>     This is a JIT related bug. Essentially the value of 'i' is in a
>     register when the exception occurs (SEGV in this case) and is lost by
>     the time the relevant handler is found.

AFAIK, the only case that may raise this kind of exception is
NullPointerException.  Any other case would be the result of calling a
soft_* function or a method, and this would have spilled all registers
before the call.  Thus, I see two alternatives:

1) #define CHECK_NULL(a,b,c) sync_registers()
   unless it is already defined in some platform-specific
   header-file.

   This would ensure that any registers are saved in the stack before
   a NullPointerException may be thrown, with a very small performance
   impact.  Only registers that are dirty and would be overwritten in
   the near future will be unnecessarily spilled; others may be
   written to the stack frame earlier and marked as clean, so they
   won't be spilled any more.

   sync_registers() does not exist on the intrp, so it may be defined
   to nothing in this case.  Furthermore, on x86, a patch that ensures
   that sync_registers() does not remove a floating-point value from
   the top of the FP stack must be installed.


2) have the SIGSEGV/SIGBUS signal catcher save registers where they
   belong.  But I'm not sure this is doable, anyway.

I strongly favor suggestion 1.

-- 
Alexandre Oliva
mailto:oliva at dcc.unicamp.br mailto:aoliva at acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil



More information about the kaffe mailing list