GithubHelp home page GithubHelp logo

hippodrome's People

Contributors

andrecostea avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

littlejlf

hippodrome's Issues

Opportunity for Validation Optimization

For a bug (snapshot, stmt_{from}, stmt_{to}), regenerate the update snapshot corresponding to stmt_{to} and just check the deadlock locally instead of calling infer all over again.

No Patch could be generate for linkedlist

Error: No patch could be generated for attempt ID

linkedlist/MyLinkedList.java:49: warning: Thread Safety Violation 2
Read/Write race. Non-private method MyLinkedList.insert(...) reads with synchronization from p._current._next. Potentially races with unsynchronized write in method MyLinkedList.insert(...).
Reporting because this access may occur on a background thread.
47. // Delete the synch block for the unsynch case
48. synchronized (this) {
49. > tmp = new MyListNode(x, p._current._next);
50. } // Extend the synch block one stmt to eliminate the bug
51. p._current._next = tmp;

linkedlist/MyLinkedList.java:51: warning: Thread Safety Violation 2
Unprotected write. Non-private method MyLinkedList.insert(...) writes to field p._current._next outside of synchronization.
Reporting because this access may occur on a background thread.
49. tmp = new MyListNode(x, p._current._next);
50. } // Extend the synch block one stmt to eliminate the bug
51. > p._current._next = tmp;
52. }
53. }

Found 2 issues
Issue Type(ISSUED_TYPE_ID): #
Thread Safety Violation 2(THREAD_SAFETY_VIOLATION_2): 2
**************** BUGS: , d7392eae2e6c045714ff854fa171b1e1, ef2fe6c07d14332d6809ca1cea6e153c *************
************* GENERATE PATCH *************
No patch could be generated for attempt ID
No patch could be generated for attempt ID

Capturing in javac mode...
Found 1 source file to analyze in /Users/tiwari/Documents/PostDoc/Paper2/Evaluation/RQ1/infer-out
linkedlist/MyLinkedList.java starting
linkedlist/MyLinkedList.java DONE

linkedlist/MyLinkedList.java:50: warning: Thread Safety Violation 2
Read/Write race. Non-private method MyLinkedList.insert(...) reads with synchronization from p._current._next. Potentially races with unsynchronized write in method MyLinkedList.insert(...).
Reporting because this access may occur on a background thread.
48. // Delete the synch block for the unsynch case
49. synchronized (this) {
50. > tmp = new MyListNode(x, p._current._next);
51. } // Extend the synch block one stmt to eliminate the bug
52. p._current._next = tmp;

linkedlist/MyLinkedList.java:52: warning: Thread Safety Violation 2
Unprotected write. Non-private method MyLinkedList.insert(...) writes to field p._current._next outside of synchronization.
Reporting because this access may occur on a background thread.
50. tmp = new MyListNode(x, p._current._next);
51. } // Extend the synch block one stmt to eliminate the bug
52. > p._current._next = tmp;
53. }
54. }

Found 2 issues
Issue Type(ISSUED_TYPE_ID): #
Thread Safety Violation 2(THREAD_SAFETY_VIOLATION_2): 2
New bugs detected during validation phase. Rerun RacerDFix? (Y/n)

Sync when locked object is indirect via method call

src/test/java/alarmclock/AlarmClock.java:191: warning: Thread Safety Violation 2
Read/Write race. Non-private method Monitor.wakeme(...) indirectly reads without synchronization from this.waitList.list.[_]. Potentially races with write in method Monitor.tick().
Reporting because this access may occur on a background thread.
189. */
190. try {
191. > synchronized (waitList.getLock(waketime)) {
192. try {
193. waitList.getLock(waketime).wait();

Wrong expression locked for conditionals

airline:

      if (Num_Of_Seats_Sold > Maximum_Capacity) 
          synchronized(obj6) { throw new RuntimeException("bug found"); }  

Patch ID: 5
Replace (INSERT) lines: 12 - 65
+: Object obj6 = new Object();
Replace (INSERT) lines: 53 - 53
-: throw new RuntimeException("bug found");
+: synchronized(obj6) { throw new RuntimeException("bug found"); }

Check lock type

Need to collect the type of the lock, otherwise we might end up creating locks on non-reference types leading to a type error in Java.

For:

       protected void haha(int x){    
       //    synchronized(myA2){
               myA.f = x;
       //    }
       }  

we currently generate:

        protected void haha(int x){     
        //    synchronized(myA2){ 
                synchronized(myA.f) {myA.f = x;} 
         
        //    } 
        }  

when we actually should generate:
we currently generate:

        protected void haha(int x){     
        //    synchronized(myA2){ 
                synchronized(myA) {myA.f = x;} 
         
        //    } 
        }  

Missed data races in Airline

Data race involving the Num_Of_Seats_Sold variable was not fixed in Airline program. Running the infer still gives this warning. The RacerDFix seemed to have terminated normally:

Found 4 issues
Issue Type(ISSUED_TYPE_ID): #
Thread Safety Violation 2(THREAD_SAFETY_VIOLATION_2): 4
New bugs detected during validation phase. Rerun RacerDFix? (Y/n)
Y
Capturing in javac mode...
Found 1 source file to analyze in /Users/tiwari/Documents/PostDoc/Paper2/Evaluation/RQ1/infer-out
airline/Main.java starting
airline/Main.java DONE

ANDREEA: report

No issues found
Capturing in javac mode...
Found 1 source file to analyze in /Users/tiwari/Documents/PostDoc/Paper2/Evaluation/RQ1/infer-out
airline/Main.java starting
airline/Main.java DONE

ANDREEA: report

No issues found

Inconsistent lock objects for related race

Synchronized blocks with different lock objects are created for the race involving the same object.
For example, in Airline program, run the RacerDFix one time (do not select the Y option) and observe the lock object at line 42, 55, 65, and 66. All locks are protecting Num_Of_Seats_Sold, but locks are not the same at these places. Making locks the same at all four places removes the infer's warning for good.

No Patch could be generated in BuggyProgram

RacerDFix failed to generate any patch for BuggyProgram. Following are the execution traces:

buggyprogram/BuggyProgram.java starting
buggyprogram/BuggyProgram.java DONE

buggyprogram/BuggyProgram.java:317: warning: Thread Safety Violation 2
Read/Write race. Non-private method BuggyProgram$User.run() reads without synchronization from buggyprogram.BuggyProgram.history.[_]. Potentially races with write in method BuggyProgram$User.record().
Reporting because the current class is annotated @ThreadSafe, so we assume that this method can run in parallel with other non-private methods in the class (including itself).
315.
316. for (i = 0; i < numOfUsers; ++i) {
317. > if (history[i] == randomNumber) {
318. break;
319. }

Found 1 issue
Issue Type(ISSUED_TYPE_ID): #
Thread Safety Violation 2(THREAD_SAFETY_VIOLATION_2): 1
**************** BUGS: , 83436a5e932ee5cf6e5ff2146eab6bc2 *************
************* GENERATE PATCH *************
No patch could be generated for attempt ID

Capturing in javac mode...
Found 1 source file to analyze in /Users/tiwari/Documents/PostDoc/Paper2/Evaluation/RQ1/infer-out
buggyprogram/BuggyProgram.java starting
buggyprogram/BuggyProgram.java DONE

buggyprogram/BuggyProgram.java:318: warning: Thread Safety Violation 2
Read/Write race. Non-private method BuggyProgram$User.run() reads without synchronization from buggyprogram.BuggyProgram.history.[_]. Potentially races with write in method BuggyProgram$User.record().
Reporting because the current class is annotated @ThreadSafe, so we assume that this method can run in parallel with other non-private methods in the class (including itself).
316.
317. for (i = 0; i < numOfUsers; ++i) {
318. > if (history[i] == randomNumber) {
319. break;
320. }

Found 1 issue
Issue Type(ISSUED_TYPE_ID): #
Thread Safety Violation 2(THREAD_SAFETY_VIOLATION_2): 1
New bugs detected during validation phase. Rerun RacerDFix? (Y/n)

Overlapping patches

Currently we are removing one of the overlapping patches. Need to find a solution which allows us to merge such patches.

eg
if(cond) stmt1 else stms2
patch1 : synchronized(obj1) {if(cond) stmt1 else stms2 }
patch2 : if(cond) stmt1 else synchronized(obj2) {stms2 }

One of the above patches will be removed

Additional closing parantheses } created while adding synch block

While running AlarmClock example from PFix benchmark, an additional } is added for the below statement:

Initial Code: synchronized(list) {list[size - 1] = null;}

Code after added Lock: synchronized(list) {synchronized(size) {list[size - 1] = null;}}}

This causes compilation failure and halts further fixing.

Automated iteration

If a file needs multiple iterations of patch generation, the latter should be performed automatically by default (for the end user). We can still keep the interactive feature for testing purposes.

Multiple unused lock objects are created

Multiple lock objects were created during the execution on the Airline program:
Object obj3 = new Object(); Object obj6 = new Object(); Object obj9 = new Object(); Object obj12 = new Object(); Object obj15 = new Object();

However, the only lock object used in this case was obj12.

Lock inside main method: non-static variable cannot be referenced from a static context

In checkfield program, a synchronized block is added in main method "ex = new InstanceExample();". As the lock object is non-static, java compilation fails with non-static variable cannot be referenced from a static context. There are two ways, I think we should address this:

  1. We should think of using the same shared variable as the lock object if we are able to verify that the shared variable is of reference type.
  2. We can create static lock objects.

scope is broken again for datarace and --atomicity=true

Patch ID: 2
Replace (INSERT) lines: 6 - 41
+: Object objR1 = new Object();
Replace (INSERT) lines: 39 - 39
-: return accounts[accountNumber].getBalance() == amount;
+: synchronized(objR1) { return accounts[accountNumber].getBalance() == amount; }

Replace (INSERT) lines: 31 - 33
-: int temp = accounts[accountNumber].getBalance();
temp = temp + amount;
accounts[accountNumber].setBalance(temp);
+: synchronized(objR1) { int temp = accounts[accountNumber].getBalance();
temp = temp + amount;
accounts[accountNumber].setBalance(temp); }

Replace (INSERT) lines: 23 - 25
-: int temp = accounts[accountNumber].getBalance();
temp = temp - amount;
accounts[accountNumber].setBalance(temp);
+: synchronized(objR1) { int temp = accounts[accountNumber].getBalance();
temp = temp - amount;
accounts[accountNumber].setBalance(temp); }

Multiple bugs involving the same snapshot

If infer detects multiple bugs involving the same access snapshot, we should attempt to solve them sequentially:

  1. prioritise on UnprotectedWrites first. Fix thme
  2. re-run the main algo (incl infer) to collect the new set of bugs. Forget about the previously detected ones.

Correct the spelling in output racerdfix_sumaaries.json file

File created after running the RacerDFix is 'racerdfix_sumaaries.json'. However, while reporting it expects 'racerdfix_summaries.json'. I think this issue is due to the spelling inconsistency. Following is the error trace:

Found 3 issues
Issue Type(ISSUED_TYPE_ID): #
Thread Safety Violation 2(THREAD_SAFETY_VIOLATION_2): 3
Exception in thread "main" java.io.FileNotFoundException: ./infer-out/racerdfix_summaries.json (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.(FileInputStream.java:138)
at scala.io.Source$.fromFile(Source.scala:92)
at scala.io.Source$.fromFile(Source.scala:77)
at scala.io.Source$.fromFile(Source.scala:55)
at org.racerdfix.utils.FileManipulation.fileToString(FileManipulation.scala:37)
at org.racerdfix.inferAPI.InterpretJson.getJsonSummaries(InterpretJson.scala:307)
at org.racerdfix.RacerDFix$.runPatchAndFix(RacerDFix.scala:117)
at org.racerdfix.RacerDFix$.handleInput(RacerDFix.scala:92)
at org.racerdfix.RacerDFix$.main(RacerDFix.scala:166)
at org.racerdfix.RacerDFix.main(RacerDFix.scala)

Missing description in Readme

This seems like a very interesting project, and from what I gathered, it builds on top of Infer to maybe detect race conditions? Maybe even generate examples?

A one paragraph description of the project in the readme would be useful for others who are curious about developments in this space.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.