ASM 4.0 RC2: Revisiting the NOP ATHROW bug

"[email protected]" <[email protected]>
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <CAOrbxLSdAgTSe_-eG-FLA=C1p2Y-hV=0pc-RCnqqVBO7abNVdQ@mail.gmail.com>
Hi All,

I've tried to integrate the ASM RC2 with Jython, but I see the NOP
ATHROW behavior still persistent. I saw a previous discussion of this on
this mailing list (at
http://old.nabble.com/NOP-ATHROW-hack-defeated-%21-tt31501819.html) and
thought that the issue was fixed, but maybe not.

Basically if Jython tries to compile this code:

def openfile():
    fullname = "tmp.txt"
    try:
        f = open(fullname, "rU")
    except IOError:
        return
  return f


The following error occurs when trying to run the code:

java.lang.VerifyError: Stack map does not match the one at exception handler
60 in method
org.python.pycode._pyx0._openfile$1(Lorg/python/core/PyFrame;Lorg/python/core/ThreadState;Lorg/python/core/PyObject;)Lorg/python/core/PyObject;
at offset 45
 at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
 at java.lang.Class.getConstructor0(Class.java:2714)
at java.lang.Class.getConstructor(Class.java:1674)
 at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:68)
at
org.python.compiler.LegacyCompiler$LazyLegacyBundle.loadCode(LegacyCompiler.java:43)
 at org.python.core.CompilerFacade.compile(CompilerFacade.java:34)
at org.python.core.Py.compile_flags(Py.java:1739)
 at org.python.core.Py.compile_flags(Py.java:1744)
at org.python.core.Py.compile_flags(Py.java:1754)
 at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:235)
at org.python.util.jython.run(jython.java:252)
 at org.python.util.jython.main(jython.java:134)


(notice the nop and athrow at 95-97 of the byte code). If I just turn off
the Java verifier, the code runs fine.

The java byte code generated for this function by Jython (with ASM RC2) is
here: http://pylonshq.com/pasties/d3cc6de01deeed29c459e38e89983ae7
(all the boiler plate has been removed). This is the smallest example
that reproduces the bug.

I saw from the previous threads that the generated ASM code would be of
help. I tried to replace my ClassFile with the ASMifier, but was unable to
get the ASM code of this particular example (the ASMifier always printed
null).
But, I was able to get the output of another python program, similar to
this, the relevant lines of the python program with the ASM code is here:
http://pylonshq.com/pasties/139f695a127a01d5dee1030b9829554b
This also produces the same bug, but this is part of a large program, so
only what I thought was relevant is kept. Of course I could be wrong here
(don't have too much ASM knowledge) so please let me know if you need more
info. I could put up the whole log up there with the generated bytecode.

Also I talked to Remi at the JVM language Summit, and he suggested that
Jython should do some code analysis to not generate this kind of code in the
first place, while I totally agree with that, I just don't want to do that
work if it can be handled by ASM :)

Please let me know if you need any further information and if I'm doing
something wrong.

Thanks,
Shashank Bharadwaj
message-footer.txt (text/plain, 238 B)
-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.