Reviewed By: sblackshear Differential Revision: D7238932 fbshipit-source-id: 923e18emaster
							parent
							
								
									fe43dc2080
								
							
						
					
					
						commit
						484480f72f
					
				| @ -0,0 +1,44 @@ | ||||
| /* | ||||
|  * Copyright (c) 2018 - present Facebook, Inc. | ||||
|  * All rights reserved. | ||||
|  * | ||||
|  * This source code is licensed under the BSD style license found in the | ||||
|  * LICENSE file in the root directory of this source tree. An additional grant | ||||
|  * of patent rights can be found in the PATENTS file in the same directory. | ||||
|  */ | ||||
| 
 | ||||
| class Interclass { | ||||
|   synchronized void interclass1_bad(InterclassA a) { | ||||
|     a.interclass1_bad(); | ||||
|   } | ||||
| 
 | ||||
|   synchronized void interclass2_bad() {} | ||||
| 
 | ||||
|   synchronized void interclass1_ok(InterclassB b) { | ||||
|     b.interclass1_ok(); | ||||
|   } | ||||
| 
 | ||||
|   void interclass2_ok(InterclassB b) { | ||||
|     synchronized(b) {} | ||||
|   } | ||||
| 
 | ||||
|   void reentrant_ok(InterclassB b) { | ||||
|     synchronized(this) { synchronized(b) { b.interclass1_ok(); } } | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| class InterclassA { | ||||
|   synchronized void interclass1_bad() {} | ||||
| 
 | ||||
|   synchronized void interclass2_bad(Interclass i) { | ||||
|     i.interclass2_bad(); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| class InterclassB { | ||||
|   synchronized void interclass1_ok() {} | ||||
| 
 | ||||
|   void interclass2_ok(Interclass c) { | ||||
|     synchronized(c) { c.interclass2_ok(this); } | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,50 @@ | ||||
| /* | ||||
|  * Copyright (c) 2018 - present Facebook, Inc. | ||||
|  * All rights reserved. | ||||
|  * | ||||
|  * This source code is licensed under the BSD style license found in the | ||||
|  * LICENSE file in the root directory of this source tree. An additional grant | ||||
|  * of patent rights can be found in the PATENTS file in the same directory. | ||||
|  */ | ||||
| 
 | ||||
| class Interproc { | ||||
|   synchronized void interproc1_bad(InterprocA a) { | ||||
|     interproc2_bad(a); | ||||
|   } | ||||
| 
 | ||||
|   void interproc2_bad(InterprocA b) { | ||||
|     synchronized(b) {} | ||||
|   } | ||||
| 
 | ||||
|   synchronized void interproc1_ok(InterprocB a) { | ||||
|     interproc2_ok(a); | ||||
|   } | ||||
| 
 | ||||
|   void interproc2_ok(InterprocB b) { | ||||
|     synchronized(b) {} | ||||
|   } | ||||
| 
 | ||||
|   void reentrant1_ok(InterprocB b) { | ||||
|     synchronized(this) { synchronized(b) { reentrant2_ok(); } } | ||||
|   } | ||||
| 
 | ||||
|   synchronized void reentrant2_ok() {} | ||||
| } | ||||
| 
 | ||||
| class InterprocA { | ||||
|   synchronized void interproc1_bad(Interproc c) { | ||||
|     interproc2_bad(c); | ||||
|   } | ||||
| 
 | ||||
|   void interproc2_bad(Interproc d) { | ||||
|     synchronized(d) {} | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| class InterprocB { | ||||
|   void interproc1_ok(Interproc c) { | ||||
|     synchronized(c) { interproc2_ok(c); } | ||||
|   } | ||||
| 
 | ||||
|   synchronized void interproc2_ok(Interproc d) {} | ||||
| } | ||||
| @ -0,0 +1,34 @@ | ||||
| /* | ||||
|  * Copyright (c) 2018 - present Facebook, Inc. | ||||
|  * All rights reserved. | ||||
|  * | ||||
|  * This source code is licensed under the BSD style license found in the | ||||
|  * LICENSE file in the root directory of this source tree. An additional grant | ||||
|  * of patent rights can be found in the PATENTS file in the same directory. | ||||
|  */ | ||||
| 
 | ||||
| class Intraproc { | ||||
|   void intra_bad(IntraprocA o) { | ||||
|     synchronized(this) { synchronized(o) {} } | ||||
|   } | ||||
| 
 | ||||
|   void intra_ok(IntraprocB o) { | ||||
|     synchronized(this) { synchronized(o) {} } | ||||
|   } | ||||
| 
 | ||||
|   void reentrant_ok(IntraprocB b) { | ||||
|     synchronized(this) { synchronized(b) { synchronized(this) {} } } | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| class IntraprocA { | ||||
|   void intra_bad(Intraproc o) { | ||||
|     synchronized(this) { synchronized(o) {} } | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| class IntraprocB { | ||||
|   void intra_ok(Intraproc o) { | ||||
|     synchronized(o) { synchronized(this) {} } | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,15 @@ | ||||
| # Copyright (c) 2018 - present Facebook, Inc.
 | ||||
| # All rights reserved.
 | ||||
| #
 | ||||
| # This source code is licensed under the BSD style license found in the
 | ||||
| # LICENSE file in the root directory of this source tree. An additional grant
 | ||||
| # of patent rights can be found in the PATENTS file in the same directory.
 | ||||
| 
 | ||||
| TESTS_DIR = ../../.. | ||||
| 
 | ||||
| ANALYZER = checkers | ||||
| INFER_OPTIONS = --deadlock-only --debug-exceptions | ||||
| INFERPRINT_OPTIONS = --issues-tests | ||||
| SOURCES = $(wildcard *.java) | ||||
| 
 | ||||
| include $(TESTS_DIR)/javac.make | ||||
| @ -0,0 +1,3 @@ | ||||
| codetoanalyze/java/deadlock/Interclass.java, void Interclass.interclass1_bad(InterclassA), 0, DEADLOCK, ERROR, [[Trace 1] Lock acquisition: locks &this in class Interclass*,Method call: void InterclassA.interclass1_bad(),Lock acquisition: locks &this in class InterclassA*,[Trace 2] Lock acquisition: locks &this in class InterclassA*,Method call: void Interclass.interclass2_bad(),Lock acquisition: locks &this in class Interclass*] | ||||
| codetoanalyze/java/deadlock/Interproc.java, void Interproc.interproc1_bad(InterprocA), 0, DEADLOCK, ERROR, [[Trace 1] Lock acquisition: locks &this in class Interproc*,Method call: void Interproc.interproc2_bad(InterprocA),Lock acquisition: locks &b in class InterprocA*,[Trace 2] Lock acquisition: locks &this in class InterprocA*,Method call: void InterprocA.interproc2_bad(Interproc),Lock acquisition: locks &d in class Interproc*] | ||||
| codetoanalyze/java/deadlock/Intraproc.java, void IntraprocA.intra_bad(Intraproc), 0, DEADLOCK, ERROR, [[Trace 1] Method start: void IntraprocA.intra_bad(Intraproc),Lock acquisition: locks &this in class IntraprocA*,Lock acquisition: locks &o in class Intraproc*,[Trace 2] Method start: void Intraproc.intra_bad(IntraprocA),Lock acquisition: locks &this in class Intraproc*,Lock acquisition: locks &o in class IntraprocA*] | ||||
					Loading…
					
					
				
		Reference in new issue