Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 3.0.1
-
Fix Version/s: 3.1.0
-
Component/s: None
-
Labels:None
-
Environment:Ubuntu 8.04 32bits
-
Number of attachments :
Description
Hello,
I added a callback for ExitMonitor that opens a file and simply writes "hello world" in it. If I close the file, the system crashes. If i don't close the file, everything is ok, just that my text does not egt
saved.
My code is:
@Override
public void notifyExit(int value) {
if (stateSaved)
try
{ FileOutputStream fos = new FileOutputStream(new File( "pastExecutions")); PrintWriter out = new PrintWriter(fos); out.println("Hello world"); out.close(); stateSaved = true; }catch (SecurityException e)
{ // TODO Auto-generated catch block e.printStackTrace(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); }}
Another question I have is how to use ObjectOutputStream, because it gives me an error when I try to use it saying it is not found. I tried to include both sun classpath and gnu classpath, unfortunately to no avail.
The stack trace generated by RVM is:
Exception in thread "MainThread": java.lang.NullPointerException
at .<invisible method>(Unknown Source:0)
at java.lang.VMThrowable.fillInStackTrace(VMThrowable.java:49)
at java.lang.Throwable.fillInStackTrace(Throwable.java:498)
at java.lang.Throwable.<init>(Throwable.java:159)
at java.lang.Throwable.<init>(Throwable.java:148)
at java.lang.Exception.<init>(Exception.java:66)
at java.lang.RuntimeException.<init>(RuntimeException.java:64)
at java.lang.NullPointerException.<init>(NullPointerException.java:69)
at org.jikesrvm.runtime.RuntimeEntrypoints.deliverHardwareException(RuntimeEntrypoints.java:621)
at .<hardware trap>(Unknown Source:0)
at java.lang.ThreadLocalMap.get(ThreadLocalMap.java:212)
at java.lang.ThreadLocal.get(ThreadLocal.java:149)
at gnu.java.nio.VMChannel$LocalByteArray.get(VMChannel.java:187)
at gnu.java.nio.VMChannel.write(VMChannel.java:401)
at gnu.java.nio.VMChannel.write(VMChannel.java:413)
at gnu.java.nio.VMChannel.write(VMChannel.java:425)
at gnu.java.nio.FileChannelImpl.write(FileChannelImpl.java:261)
at java.io.FileOutputStream.write(FileOutputStream.java:279)
at java.io.FileOutputStream.write(FileOutputStream.java:262)
at java.io.OutputStreamWriter.writeConvert(OutputStreamWriter.java:364)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:300)
at java.io.OutputStreamWriter.close(OutputStreamWriter.java:270)
at java.io.PrintWriter.close(PrintWriter.java:259)
at org.jikesrvm.scheduler.greenthreads.NextThreadChooser.notifyExit(NextThreadChooser.java:259)
at org.jikesrvm.Callbacks.notifyExit(Callbacks.java:800)
at org.jikesrvm.VM.sysExit(VM.java:2418)
at java.lang.VMRuntime.exit(VMRuntime.java:81)
at java.lang.Runtime.halt(Runtime.java:396)
at java.lang.Runtime.exit(Runtime.java:174)
JikesRVM: internal error: recursive use of hardware exception registers (exiting)
– Stack –
at Ljava/lang/JikesRVMSupport; threadDied(Ljava/lang/Thread;)V at line 112
at Lorg/jikesrvm/scheduler/RVMThread; terminate()V at line 712
at Lorg/jikesrvm/scheduler/RVMThread; handleUncaughtException(Ljava/lang/Throwable;)V at line 1910
at Lorg/jikesrvm/runtime/RuntimeEntrypoints; handleUncaughtException(Ljava/lang/Throwable;)V at line 978
at Lorg/jikesrvm/runtime/RuntimeEntrypoints; deliverException(Ljava/lang/Throwable;Lorg/jikesrvm/ArchitectureSpecific$Registers;)V at line 973
at Lorg/jikesrvm/runtime/RuntimeEntrypoints; athrow(Ljava/lang/Throwable;)V at line 595
at Lorg/jikesrvm/Callbacks; notifyExit(I)V at line 802
at Lorg/jikesrvm/VM; sysExit(I)V at line 2418
at Ljava/lang/VMRuntime; exit(I)V at line 81
at Ljava/lang/Runtime; halt(I)V at line 399
at Ljava/lang/Runtime; exit(I)V at line 174
at Ljava/lang/System; exit(I)V at line 577
at Lorg/jikesrvm/scheduler/RVMThread; terminate()V at line 788
at Lorg/jikesrvm/scheduler/RVMThread; startoff()V at line 652
********************************************************************************
- Abnormal termination of Jikes RVM *
- Jikes RVM terminated abnormally indicating a problem in the virtual machine. *
- Jikes RVM relies on community support to get debug information. Help improve *
- Jikes RVM for everybody by reporting this error. Please see: *
- http://jikesrvm.org/Reporting+Bugs *
********************************************************************************
Proc 1: Thread 11: VM.sysExit(): We're in an (unambiguously) recursive call to VM.sysExit(), 2 deep
Thanks,
silviu
the ExitMonitor callback is happening too late in VM shutdown to let you actually do file I/O. I've been meaning to get rid of it actually...
a more robust way to hook shutdown is to use java.lang.Runtime.addShutdownHook