[Soot-list] Synchronized Sections and soot.

Richard L. Halpert richhal22 at gmail.com
Mon Feb 15 13:51:00 EST 2010


Technically, all you can count on in Java Bytecode is what's required by the
JVM spec (http://java.sun.com/docs/books/jvms/).  If your bytecode comes
from Java source, you get a few more guarantees (mainly that the monitorexit
will be in the same method as the monitorenter, which is something that JVMs
are allowed, but not required, to enforce anyways).  Fortunately, in
practice it's possible to find synchronized regions pretty consistently.  In
my work on Lock Allocation, I wrote code that finds synchronized regions
based on the assumptions that there will be one entry point (a monitorenter
instruction), any number of exit points, and at least one exceptional exit
that forces the use of a monitorexit instruction (essentially, a finally
clause).  This code is described in my thesis (section 3.2.2 of
http://www.sable.mcgill.ca/publications/thesis/#richardsMastersThesis), and
can be found in the soot source:
soot.jimple.toolkits.thread.synchronization.SynchronizedRegionFinder and
associated classes.  Note, though, that my code does make some assumptions
beyond what is guaranteed by the JVM spec and the Java language spec.

-Richard

On Sat, Feb 13, 2010 at 2:16 AM, Eric Bodden <
bodden at st.informatik.tu-darmstadt.de> wrote:

> Hi Richard.
>
> This really depends where the Jimple code originates from. If Soot
> produces it from source then there may be some regularity about the
> way that Soot produces the code. If Soot produces Jimple from
> bytecode, however, then Soot will give you Jimple that does exactly
> whatever the bytecode does. In general there is no structural
> constraints on how to generate code for synchronized blocks as long as
> the code happens to do the right thing at runtime, i.e., lock and
> unlock locks at appropriate times and in the right order.
>
> So quite likely your code will break when reading in bytecode
> generated from certain compilers.
>
> Eric
>
> --
> Dr. Eric Bodden
> Software Technology Group, Technische Universität Darmstadt, Germany
> Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
> Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt
>
>
>
> On 12 February 2010 20:39, Richard Gill <rg06 at doc.ic.ac.uk> wrote:
> > Hi All,
> > I have used Soot in order to find synchronized sections and some of my
> work
> > is based on an assumption of how soot represents this in Jimple.
> > It is my understanding that the last exitmonitor statement (when you go
> down
> > the program line by line), is always followed by a throw statement. This
> is
> > effectively a try catch which is injected inside the synchronize. Can I
> > verify that this injected exitmonitor followed by a throw statement will
> > always come last? If it doesn't then my assumptions are incorrect and my
> > implementation will probably break at some point.
> > Thanks,
> > Richard
> > _______________________________________________
> > Soot-list mailing list
> > Soot-list at sable.mcgill.ca
> > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> >
> >
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20100215/351bf1f6/attachment.html 


More information about the Soot-list mailing list