Re: Re: NOP ATHROW hack defeated !
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <1606362175.4220861307603710620.JavaMail.root@zimbra7-e1.priv.proxad.net> |
the ASM patch I sent a few weeks ago had a bug: it was updating the exception handler list, without updating the number of elements in this list (in 'handlerCount'). Here is a new version which fixes this issue. Does it solve your problem? Eric 07/06/2011 23:02, Charles Oliver Nutter wrote: > Sorry, here's that link. > > https://gist.github.com/1013088 > > On Tue, Jun 7, 2011 at 4:02 PM, Charles Oliver Nutter > <[email protected]> wrote: >> Ok, here's ASMifier output of a class that breaks. I turned off stack >> map calculation so it wouldn't do the rewriting. Hopefully modifying >> this to turn the stack map calculation back on will trigger the >> problem. I'll play with it more, but this is at least a start at it... >> >> - Charlie >> >> On Tue, Jun 7, 2011 at 3:24 PM, Charles Oliver Nutter >> <[email protected]> wrote: >>> Trying to get you something right now; It will probably have JRuby >>> dependencies, but I can try to strip them out later if possible. At >>> least it will give you an example to go on. >>> >>> - Charlie >>> >>> On Sat, May 21, 2011 at 4:58 AM, Eric Bruneton<[email protected]> wrote: >>>> 18/05/2011 22:28, Charles Oliver Nutter wrote: >>>>> >>>>> Now I have a case where the ASM dead code rewriting breaks on Java 7 >>>>> but not Java 6: >>>>> So it's a while loop with a break inside a rescued method body. The >>>>> code emitted for the while loop looks like this: >>>>> >>>>> L5 >>>>> LINENUMBER 2 L5 >>>>> GOTO L6 >>>>> L7 >>>>> L8 >>>>> LINENUMBER 3 L8 >>>>> ALOAD 1 >>>>> GETFIELD org/jruby/runtime/ThreadContext.nil : >>>>> Lorg/jruby/runtime/builtin/IRubyObject; >>>>> GOTO L9 >>>>> L10 >>>>> POP >>>>> L6 >>>>> ALOAD 9 >>>>> INVOKEINTERFACE org/jruby/runtime/builtin/IRubyObject.isTrue ()Z >>>>> IFNE L7 >>>> >>>> can you send us the corresponding ASMifier code (for the whole >>>> method/class), so that we can reproduce the bug? >>>> >>>> Eric >>>> >>> >> >
deadcode.patch
(application/octet-stream, 3 KB)
Index: org/objectweb/asm/Handler.java
===================================================================
--- org/objectweb/asm/Handler.java (revision 1498)
+++ org/objectweb/asm/Handler.java (working copy)
@@ -67,4 +67,52 @@
* Next exception handler block info.
*/
Handler next;
+
+ /**
+ * Removes the range between start and end from the given exception
+ * handlers.
+ *
+ * @param h an exception handler list.
+ * @param start the start of the range to be removed.
+ * @param end the end of the range to be removed. Maybe null.
+ * @return the exception handler list with the start-end range removed.
+ */
+ static Handler remove(Handler h, Label start, Label end) {
+ if (h == null) {
+ return null;
+ } else {
+ h.next = remove(h.next, start, end);
+ }
+ int hstart = h.start.position;
+ int hend = h.end.position;
+ int s = start.position;
+ int e = end == null ? Integer.MAX_VALUE : end.position;
+ // if [hstart,hend[ and [s,e[ intervals intersect...
+ if (s < hend && e > hstart) {
+ boolean i = s <= hstart;
+ boolean j = e >= hend;
+ if (i && j) {
+ // [hstart,hend[ fully included in [s,e[, h removed
+ h = h.next;
+ } else if (i && !j) {
+ // [hstart,hend[ minus [s,e[ = [hstart,e[
+ h.end = end;
+ } else if (!i && j) {
+ // [hstart,hend[ minus [s,e[ = [s,hend[
+ h.start = start;
+ } else { // !i && !j
+ // [hstart,hend[ minus [s,e[ = [hstart,s[ + [e,hend[
+ Handler g = new Handler();
+ g.start = end;
+ g.end = h.end;
+ g.handler = h.handler;
+ g.desc = h.desc;
+ g.type = h.type;
+ g.next = h.next;
+ h.end = start;
+ h.next = g;
+ }
+ }
+ return h;
+ }
}
Index: org/objectweb/asm/MethodWriter.java
===================================================================
--- org/objectweb/asm/MethodWriter.java (revision 1498)
+++ org/objectweb/asm/MethodWriter.java (working copy)
@@ -1366,11 +1366,20 @@
frame[frameIndex++] = Frame.OBJECT
| cw.addType("java/lang/Throwable");
endFrame();
+ // removes the start-end range from the exception handlers
+ firstHandler = Handler.remove(firstHandler, l, k);
}
}
l = l.successor;
}
+ handler = firstHandler;
+ handlerCount = 0;
+ while (handler != null) {
+ handlerCount += 1;
+ handler = handler.next;
+ }
+
this.maxStack = max;
} else if (compute == MAXS) {
// completes the control flow graph with exception handler blocks
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