[Soot-list] Fwd: Support for Thread.start()

ASHISH MISHRA ashish123.mishragkp at gmail.com
Fri May 10 05:46:34 EDT 2013


Hi All,

I have a doubt regarding adding an edge from MainThead.start() to run()
method of the worker class, Adding an egde like this assumes a Synchronous
method call from t.start() to run(), while in actual java semantic , the
method MainThrea.start() will just start the new Thread and return to the
main thread , thus the control comes back to the main thread before the
worker thread finishes.


E.g.

main (){
 MyTherad myt = new MyTherad();
 myt.start();

while(true){
//do something
}

}

class MyTherad extends Thread{
 @Override
public void run(){
int counter=0;
while(counter < 100){
try{
MyTherad.sleep(10);
System.out.println("Inside main Thread ");
 }catch (Exception e) {
// TODO: handle exception
}
counter++;
}
}
}


In this example the thread MyThread wont even get a chance to run , due to
an infinite loop in the main thread, but adding an edge from start to run
doesnt imply this .

NOTE- So my question falls back to , How does soot handles Asynchronous
call in the program(If it currently can )?


Please help me on this.





On Tue, Feb 12, 2013 at 11:37 PM, ASHISH MISHRA <
ashish123.mishragkp at gmail.com> wrote:

> Hi ,
>
> Yes , its the same issue Ondrej, I also tried with the  -*full-resolve*option of soot, thinking that this might be the reason the call is not
> resolved. But the issue persist.
>
> Ashish
>
>
> On Tue, Feb 12, 2013 at 10:12 PM, Ondřej Lhoták <olhotak at uwaterloo.ca>wrote:
>
>> I was going to say the same thing that Tony Yan just said. The only
>> magic that the VM (or native code in the library) does is that
>> Thread.start calls Thread.run on a new thread. Therefore, this
>> is the only behaviour that Soot handles specially. If the Thread object
>> has a Runnable that was passed into its constructor, it is then the
>> Thread.run method that calls run on that Runnable. That method is
>> just Java, so Soot does not need to have any special handling
>> for it.
>>
>> Isn't this the same issue that ASHISH MISHRA is just asking about on
>> another thread on this list?
>>
>> Ondřej
>>
>> On Tue, Feb 12, 2013 at 12:46:30PM +0100, Eric Bodden wrote:
>> > Hi Salim.
>> >
>> > I guess the best person to answer this would be Ondrej.
>> >
>> > I have cc'ed him in this message.
>> >
>> > Eric
>> >
>> > On 11 February 2013 22:14, salim bansal <salim.bansal at gmail.com> wrote:
>> > >
>> > > Thanks a lot for reply Eric.
>> > > Yes I don't have these edges in my call graph.
>> > > My understanding is(please correct me if I am wrong)
>> > > edges are getting added in "private void findReceivers(SootMethod m,
>> Body
>> > > b)" method of
>> > > OnFlyCallGraphBuilder.java. There is an "if" statement which checks if
>> > > method signature is "void start()" and
>> > > if it is then add a call to run() method of the receiver class. I
>> think
>> > > which is perfectly fine for threads that are
>> > > created by extending the thread class and overriding the run() method
>> but
>> > > would not work(wrong?) if the thread is created by passing a Runnable
>> to
>> > > Thread constructor as the run() method is inside the argument class
>> that
>> > > implements Runnable.
>> > > The code that I am trying to analyze looks like this
>> > >
>> > > Thread p_thread ; //Class variable
>> > >
>> > > ...
>> > > ...
>> > > ...
>> > >
>> > > void method1(){
>> > >
>> > > p_thread = new Thread(new Worker());
>> > >
>> > > }
>> > >
>> > > void method2(){
>> > >
>> > > p_thread.start()
>> > >
>> > > }
>> > >
>> > > ...
>> > > ...
>> > >
>> > > Worker implements Runnable{
>> > >
>> > > public void run(){
>> > >
>> > > ...
>> > > ...
>> > >
>> > > }
>> > >
>> > > }
>> > >
>> > > now I need the call "p_thread.start()" to get "directed" to
>> Worker.run()
>> > > method but with the above mentioned settings this is not working.
>> > >
>> > >
>> > > Thanks
>> > > Salim
>> > >
>> > > On Mon, Feb 11, 2013 at 3:53 AM, Eric Bodden <
>> eric.bodden at ec-spride.de>
>> > > wrote:
>> > >>
>> > >> Hi Salim.
>> > >>
>> > >> Are you saying your call graph is missing those edges? Normally they
>> > >> should just be there....
>> > >>
>> > >> Eric
>> > >>
>> > >> On 10 February 2013 23:34, salim bansal <salim.bansal at gmail.com>
>> wrote:
>> > >> > Hi,
>> > >> >
>> > >> > I am trying to build call graph with spark and cs-demand set to
>> true.
>> > >> > When a statement such as following:
>> > >> >          Thread t = new Thread (new Worker());
>> > >> >
>> > >> > ...
>> > >> > ...
>> > >> > t.start()
>> > >> >
>> > >> > is encountered.
>> > >> > I need  the call graph to have edge from t.start() to run method of
>> > >> > Worker
>> > >> > class, assuming Worker class implements Runnable.
>> > >> > How can I get this working I am using Soot 2.3.0.
>> > >> > My soot options  are
>> > >> >         opt.put("enabled","true");
>> > >> >         opt.put("verbose","true");
>> > >> >         opt.put("propagator","worklist");
>> > >> >         opt.put("set-impl","double");
>> > >> >         opt.put("double-set-old","hybrid");
>> > >> >         opt.put("double-set-new","hybrid");
>> > >> >         opt.put("cs-demand","true");
>> > >> >         opt.put("on-fly-cg","true");
>> > >> >         opt.put("ignore-types","false");
>> > >> >         opt.put("passes","10");
>> > >> >
>> > >> > Thanks
>> > >> > Salim
>> > >> >
>> > >> >
>> > >> > _______________________________________________
>> > >> > Soot-list mailing list
>> > >> > Soot-list at sable.mcgill.ca
>> > >> > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>> > >> >
>> > >>
>> > >>
>> > >>
>> > >> --
>> > >> Eric Bodden, Ph.D., http://sse.ec-spride.de/ http://bodden.de/
>> > >> Head of Secure Software Engineering Group at EC SPRIDE
>> > >> Tel: +49 6151 16-75422    Fax: +49 6151 16-72051
>> > >> Room 3.2.14, Mornewegstr. 30, 64293 Darmstadt
>> > >
>> > >
>> > >
>> > >
>> > > _______________________________________________
>> > > Soot-list mailing list
>> > > Soot-list at sable.mcgill.ca
>> > > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>> > >
>> >
>> >
>> >
>> > --
>> > Eric Bodden, Ph.D., http://sse.ec-spride.de/ http://bodden.de/
>> > Head of Secure Software Engineering Group at EC SPRIDE
>> > Tel: +49 6151 16-75422    Fax: +49 6151 16-72051
>> > Room 3.2.14, Mornewegstr. 30, 64293 Darmstadt
>> >
>> _______________________________________________
>> Soot-list mailing list
>> Soot-list at sable.mcgill.ca
>> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>>
>
>
>
> --
> Regards,
> Ashish Mishra
> Graduate Student,
> Computer Science and Automation Department,IISc
> Cell : +91-9611194714
> Mailto : ashishmishra at csa.iisc.ernet.in
>
>


-- 
Regards,
Ashish Mishra
Graduate Student,
Computer Science and Automation Department,IISc
Cell : +91-9611194714
Mailto : ashishmishra at csa.iisc.ernet.in
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20130510/71559e63/attachment-0001.html 


More information about the Soot-list mailing list