jvm crash when trying to instrument java.io.FileOutputStream
stefanegli Sep 16, 2009 5:57 AMOne can arguably challenge whether instrumenting such core methods like java.io.FileOutputStream.write(byte[],int,int) makes sense in the first place. But nonetheless I tried this using the following rule:
RULE writeBytes CLASS java.io.FileOutputStream METHOD write(byte[],int,int) HELPER org.jboss.byteman.rule.helper.Helper AT ENTRY BIND len:int=$3 IF true DO debug("Writing "+len+" bytes") ENDRULE
This repetedly produces the following - nice - JVM crash:
# # An unexpected error has been detected by Java Runtime Environment: # # Internal Error (exceptions.cpp:367), pid=5420, tid=520 # Error: ExceptionMark destructor expects no pending exceptions # # Java VM: Java HotSpot(TM) Client VM (10.0-b22 mixed mode windows-x86) # An error report file with more information is saved as: # C:\eclipse\hs_err_pid5420.log # # If you would like to submit a bug report, please visit: # http://java.sun.com/webapps/bugreport/crash.jsp # *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at ../../../src/share/instrument/JPLISAgent.c line: 806 *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at ../../../src/share/instrument/JPLISAgent.c line: 806 *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at ../../../src/share/instrument/JPLISAgent.c line: 806 *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at ../../../src/share/instrument/JPLISAgent.c line: 806 *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at ../../../src/share/instrument/JPLISAgent.c line: 806 *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at ../../../src/share/instrument/JPLISAgent.c line: 806 *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at ../../../src/share/instrument/JPLISAgent.c line: 806 *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at ../../../src/share/instrument/JPLISAgent.c line: 806
My first guess would be that we have a conflict here between the instrumentation code trying to change a class' bytecode and probably writing something somewhere using FileOutputStream.
I tried both with and without org.jboss.byteman.compileToBytecode - no help there.
On another note: Tried instrumenting those native methods of FileOutputStream but saw no effect. Can you instrument native methods at all? (using AT ENTRY for example)