skip to main content
10.1145/1375581.1375600acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
research-article

SharC: checking data sharing strategies for multithreaded c

Published:07 June 2008Publication History

ABSTRACT

Unintended or unmediated data sharing is a frequent cause of insidious bugs in multithreaded programs. We present a tool called SharC (short for Sharing Checker) that allows a user to write lightweight annotations to declare how they believe objects are being shared between threads in their program. SharC uses a combination of static and dynamic analyses to check that the program conforms to this specification.

SharC allows any type to have one of five "sharing modes" -- private to the current thread, read-only, shared under the control of a specified lock, intentionally racy, or checked dynamically. The dynamic mode uses run-time checking to verify that objects are either read-only, or only accessed by one thread. This allows us to check programs that would be difficult to check with a purely static system. If the user does not give a type an explicit annotation, then SharC uses a static type-qualifier analysis to infer that it is either private or should be checked dynamically.

SharC allows objects to move between different sharing modes at runtime by using reference counting to check that there are no other references to the objects when they change mode.

SharC's baseline dynamic analysis can check any C program, but is slow, and will generate false warnings about intentional data sharing. As the user adds more annotations, false warnings are reduced, and performance improves.We have found in practice that very few annotations are needed to describe all sharing and give reasonable performance. We ran SharC on 6 legacy C programs, summing to over 600k lines of code, and found that a total of only 60 simple annotations were needed to remove all false positives and to reduce performance overhead to only 2-14%.

References

  1. Agarwal, R., Sasturkar, A.,Wang, L., and Stoller, S. D. Optimized run-time race detection and atomicity checking using partial discovered types. In ASE?05. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Anderson, Z. R., Gay, D., Ennals, R., and Brewer, E. SharC: Checking data sharing strategies for multithreaded C. Tech. Rep. UCB/EECS-2008-25, EECS Department, University of California, Berkeley, Mar 2008.Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Boyapati, C., Lee, R., and Rinard, M. Ownership types for safe programming: preventing data races and deadlocks. In OOPSLA?02, pp. 211--230. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Cheng, G.-I., Feng, M., Leiserson, C. E.,Randall, K. H., and Stark, A. F. Detecting data races in Cilk programs that use locks. In SPAA?98, pp. 298--309. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Choi, J.-D., Lee, K., Loginov, A., O?Callahan, R., Sarkar, V., and Sridharan, M. Efficient and precise datarace detection for multithreaded object-oriented programs. In PLDI?02, pp. 258--269. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Condit, J., Harren, M., Anderson, Z., Gay, D., and Necula, G. Dependent types for low-level programming. In ESOP?07. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Elmas, T., Qadeer, S., and Tasiran, S. Goldilocks: a race and transaction-aware Java runtime. In PLDI?07, pp. 245--255. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Engler, D., and Ashcraft, K. RacerX: effective, static detection of race conditions and deadlocks. In SOSP?03, pp. 237--252. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Flanagan, C., and Freund, S. N. Atomizer: a dynamic atomicity checker for multithreaded programs. In POPL?04, pp. 256--267. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Foster, J. S., Fahndrich, M., and Aiken, A. A theory of type qualifiers. In PLDI?99, pp. 192--203. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. freedesktop.org. Gstreamer: Open source multimedia framework. http://gstreamer.freedesktop.org/.Google ScholarGoogle Scholar
  12. Frigo, M. A fast Fourier transform compiler. In PLDI?99, pp. 169--180. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Gay, D., Ennals, R., and Brewer, E. Safe manual memory management. In ISMM?07 (New York, NY, USA, 2007), ACM, pp. 2--14. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Grossman, D. Type-safe multithreading in Cyclone.Google ScholarGoogle Scholar
  15. Henzinger, T. A., Jhala, R., and Majumdar, R. Race checking by context inference. In PLDI?04, pp. 1--13. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Levanoni, Y., and Petrank, E. An on-the-fly reference-counting garbage collector for Java. ACM Transactions on Programming Languages and Systems 28, 1 (2006), 1--69. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Naik, M., Aiken, A., and Whaley, J. Effective static race detection for Java. In PLDI?06, pp. 308--319. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Necula, G. C., Condit, J., Harren, M.,McPeak, S., and Weimer, W. CCured: Type-safe retrofitting of legacy software. ACM Transactions on Programming Languages and Systems 27, 3 (May 2005). Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Pratikakis, P., Foster, J. S., and Hicks, M. Locksmith: contextsensitive correlation analysis for race detection. In PLDI?06, pp. 320--331. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Qadeer, S., and Wu, D. KISS: keep it simple and sequential. In PLDI?04, pp. 14--24. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Sasturkar, A.,Agarwal, R.,Wang, L., and Stoller, S. D. Automated type-based analysis of data races and atomicity. In PPoPP?05, pp. 83--94. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Savage, S., Burrows, M., Nelson, G., Sobalvarro, P., and Anderson, T. Eraser: a dynamic data race detector for multi-threaded programs. In SOSP?97, pp. 27--37. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Sen, K., and Agha, G. A race-detection and flipping algorithm for automated testing of multi-threaded programs. In Haifa Verification Conference (2006), pp. 166--182. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. US-CERT. Technical cyber security alerts. http://www.us-cert.gov/cas/techalerts/index.html.Google ScholarGoogle Scholar
  25. Voung, J. W., Jhala, R., and Lerner, S. RELAY: static race detection on millions of lines of code. In ESEC-FSE?07, pp. 205--214. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Yu, Y., Rodeheffer, T., and Chen,W. Racetrack: efficient detection of data race conditions via adaptive tracking. In SOSP?05, pp. 221--234. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. SharC: checking data sharing strategies for multithreaded c

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Conferences
      PLDI '08: Proceedings of the 29th ACM SIGPLAN Conference on Programming Language Design and Implementation
      June 2008
      396 pages
      ISBN:9781595938602
      DOI:10.1145/1375581
      • General Chair:
      • Rajiv Gupta,
      • Program Chair:
      • Saman Amarasinghe
      • cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 43, Issue 6
        PLDI '08
        June 2008
        382 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/1379022
        Issue’s Table of Contents

      Copyright © 2008 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 7 June 2008

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Author Tags

      Qualifiers

      • research-article

      Acceptance Rates

      Overall Acceptance Rate406of2,067submissions,20%

      Upcoming Conference

      PLDI '24

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader