Goldilocks: Efficiently Computing the Happens-Before Relation Using Locksets

  • Tayfun Elmas
  • Shaz Qadeer
  • Serdar Tasiran
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4262)


We present a new lockset-based algorithm, Goldilocks, for precisely computing the happens-before relation and thereby detecting data-races at runtime. Dynamic race detection algorithms in the literature are based on vector clocks or locksets. Vector-clock-based algorithms precisely compute the happens-before relation but have significantly more overhead. Previous lockset-based race detection algorithms, on the other hand, are imprecise. They check adherence to a particular synchronization discipline, i.e., a sufficient condition for race freedom and may generate false race warnings. Our algorithm, like vector clocks, is precise, yet it is efficient since it is purely lockset based.

We have implemented our algorithm inside the Kaffe Java Virtual Machine. Our implementation incorporates lazy evaluation of locksets and certain “short-circuit checks” which contribute significantly to its efficiency. Experimental results indicate that our algorithm’s overhead is much less than that of the vector-clock algorithm and is very close to our implementation of the Eraser lockset algorithm.


Concurrent Program Race Condition Java Virtual Machine Data Race Variable Access 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Boyapati, C., Lee, R., Rinard, M.: A type system for preventing data races and deadlocks in Java programs. In: OOPSLA 2002: Object-Oriented Programming, Systems, Languages and Applications, pp. 211–230. ACM, New York (2002)Google Scholar
  2. 2.
    Cheng, G.I., Feng, M., Leiserson, C.E., Randall, K.H., Stark, A.F.: Detecting data races in cilk programs that use locks. In: Proceedings of the ACM Symposium on Parallel Algorithms and Architectures (SPAA 1998), Puerto Vallarta, Mexico, June 28–July 2, pp. 298–309 (1998)Google Scholar
  3. 3.
    Choi, J.D., Loginov, A., Sarkar, V.: Static datarace analysis for multithreaded object-oriented programs. Technical Report RC22146, IBM Research (2001)Google Scholar
  4. 4.
    Choi, J.-D., Lee, K., Loginov, A., O’Callahan, R., Sarkar, V., Sridharan, M.: Efficient and precise datarace detection for multithreaded object-oriented programs. In: PLDI 2002: Programming Language Design and Implementation, pp. 258–269. ACM, New York (2002)CrossRefGoogle Scholar
  5. 5.
    Christiaens, M., De Bosschere, K.: Trade, a topological approach to on-the-fly race detection in Java programs. In: JVM 2001: Java Virtual Machine Research and Technology Symposium, USENIX, pp. 105–116 (2001)Google Scholar
  6. 6.
    Elmas, T., Qadeer, S., Tasiran, S.: Goldilocks: Efficiently Computing the Happens-Before Relation Using Locksets (2006), Full version available at:
  7. 7.
    Flanagan, C., Freund, S.N.: Type-based race detection for Java. In: PLDI 2000: Programming Language Design and Implementation, pp. 219–232. ACM, New York (2000)CrossRefGoogle Scholar
  8. 8.
    Flanagan, C., Godefroid, P.: Dynamic partial-order reduction for model checking software. In: POPL 2005: Principles of Programming Languages, pp. 110–121. ACM Press, New York (2005)Google Scholar
  9. 9.
    Harrow, J.J.: Runtime checking of multithreaded applications with visual threads. In: Havelund, K., Penix, J., Visser, W. (eds.) SPIN 2000. LNCS, vol. 1885, pp. 331–342. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  10. 10.
    Manson, J., Pugh, W., Adve, S.: The Java memory model. In: POPL 2005: Principles of Programming Languages, pp. 378–391. ACM Press, New York (2005)Google Scholar
  11. 11.
    Mattern, F.: Virtual time and global states of distributed systems. In: International Workshop on Parallel and Distributed Algorithms, pp. 215–226. North-Holland, Amsterdam (1989)Google Scholar
  12. 12.
    Netzer, R.H.B., Miller, B.P.: What are race conditions?: Some issues and formalizations. ACM Lett. Program. Lang. Syst. 1(1), 74–88 (1992)CrossRefGoogle Scholar
  13. 13.
    Pozniansky, E., Schuster, A.: Efficient on-the-fly race detection in multithreaded c++ programs. In: PPoPP 2003: Principles and Practice of Parallel Programming, pp. 179–190. ACM, New York (2003)CrossRefGoogle Scholar
  14. 14.
    Ronsse, M., De Bosschere, K.: Recplay: A fully integrated practical record/replay system. ACM Transactions on Computer Systems 17(2), 133–152 (1999)CrossRefGoogle Scholar
  15. 15.
    Savage, S., Burrows, M., Nelson, G., Sobalvarro, P., Anderson, T.: Eraser: A dynamic data race detector for multithreaded programs. ACM Transactions on Computer Systems 15(4), 391–411 (1997)CrossRefGoogle Scholar
  16. 16.
    Schonberg, E.: On-the-fly detection of access anomalies. In: PLDI 1989: Programming Language Design and Implementation, pp. 313–327 (1989)Google Scholar
  17. 17.
    von Praun, C., Gross, T.R.: Object race detection. In: OOPSLA 2001: Object-Oriented Programming, Systems, Languages and Applications, pp. 70–82. ACM, New York (2001)Google Scholar
  18. 18.
    Wilkinson, T.: Kaffe: A JIT and interpreting virtual machine to run Java code (1998),
  19. 19.
    Yu, Y., Rodeheffer, T., Chen, W.: Racetrack: efficient detection of data race conditions via adaptive tracking. In: SOSP 2005: Symposium on Operating Systems Principles, pp. 221–234. ACM, New York (2005)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Tayfun Elmas
    • 1
  • Shaz Qadeer
    • 2
  • Serdar Tasiran
    • 1
  1. 1.Koç University 
  2. 2.Microsoft Research 

Personalised recommendations