skip to main content
research-article
Open Access

Fencing off go: liveness and safety for channel-based programming

Published:01 January 2017Publication History
Skip Abstract Section

Abstract

Go is a production-level statically typed programming language whose design features explicit message-passing primitives and lightweight threads, enabling (and encouraging) programmers to develop concurrent systems where components interact through communication more so than by lock-based shared memory concurrency. Go can only detect global deadlocks at runtime, but provides no compile-time protection against all too common communication mismatches or partial deadlocks.

This work develops a static verification framework for bounded liveness and safety in Go programs, able to detect communication errors and partial deadlocks in a general class of realistic concurrent programs, including those with dynamic channel creation and infinite recursion. Our approach infers from a Go program a faithful representation of its communication patterns as a behavioural type. By checking a syntactic restriction on channel usage, dubbed fencing, we ensure that programs are made up of finitely many different communication patterns that may be repeated infinitely many times. This restriction allows us to implement bounded verification procedures (akin to bounded model checking) to check for liveness and safety in types which in turn approximates liveness and safety in Go programs. We have implemented a type inference and liveness and safety checks in a tool-chain and tested it against publicly available Go programs.

Updated on 27th Feb 2017. See Comments.

Skip Supplemental Material Section

Supplemental Material

References

  1. Collection of Golang concurrency patterns. https://github. com/stillwater-sc/concurrency.Google ScholarGoogle Scholar
  2. Tool chain. http://mrg.doc.ic.ac.uk/tools/gong.Google ScholarGoogle Scholar
  3. V. Agababov, M. Buettner, V. Chudnovsky, M. Cogan, B. Greenstein, S. McDaniel, M. Piatek, C. Scott, M. Welsh, and B. Yin. Flywheel: Google’s Data Compression Proxy for the Mobile Web. In NSDI 2015, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. D. G. Anderson. Experience with ePaxos: Systems Research using Go. 2013. https://da-data.blogspot.co.uk/2013/10/ experience-with-epaxos-systems-research.html.Google ScholarGoogle Scholar
  5. Andrew Gerrand. Share Memory By Communicating. https:// blog.golang.org/share-memory-by-communicating.Google ScholarGoogle Scholar
  6. D. Brand and P. Zafiropulo. On communicating finite-state machines. J. ACM, 30:323–342, April 1983. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. N. Busi, M. Gabbrielli, and G. Zavattaro. Replication vs. recursive definitions in channel based calculi. In ICALP’03, pages 133–144, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. N. Busi, M. Gabbrielli, and G. Zavattaro. Comparing recursion, replication, and iteration in process calculi. In ICALP’04, pages 307– 319, 2004.Google ScholarGoogle ScholarCross RefCross Ref
  9. L. Caires and F. Pfenning. Session types as intuitionistic linear propositions. In CONCUR, volume 6269 of LNCS, pages 222–236. Springer, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. L. Caires, F. Pfenning, and B. Toninho. Linear logic propositions as session types. Mathematical Structures in Computer Science, 26(3):367–423, 2016.Google ScholarGoogle ScholarCross RefCross Ref
  11. M. Carbone, O. Dardha, and F. Montesi. Progress as compositional lock-freedom. In COORDINATION, volume 8459 of LNCS, pages 49–64. Springer, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. S. Chaki, S. K. Rajamani, and J. Rehof. Types as models: model checking message-passing programs. In POPL’02, pages 45–57, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. M. Coppo, M. Dezani-Ciancaglini, and N. Yoshida. Asynchronous Session Types and Progress for Object-Oriented Languages. In FMOODS’07, volume 4468 of LNCS, pages 1–31, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. M. Coppo, M. Dezani-Ciancaglini, N. Yoshida, and L. Padovani. Global Progress for Dynamically Interleaved Multiparty Sessions. MSCS, 26(2):238–302, 2016.Google ScholarGoogle Scholar
  15. S. Debois, T. T. Hildebrandt, T. Slaats, and N. Yoshida. Type-checking liveness for collaborative processes with bounded and unbounded recursion. Logical Methods in Computer Science, 12(1), 2016.Google ScholarGoogle Scholar
  16. B. Fitzpatrick. go 1.5.1 linux/amd64 deadlock detection failed, 2015. https://github.com/golang/go/issues/12734# issuecomment-142859447.Google ScholarGoogle Scholar
  17. E. Giachino, N. Kobayashi, and C. Laneve. Deadlock analysis of unbounded process networks. In CONCUR, volume 8704 of LNCS, pages 63–77. Springer, 2014.Google ScholarGoogle Scholar
  18. C. Hoare. Communicating Sequential Processes. Prentice Hall, 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. K. Honda, V. T. Vasconcelos, and M. Kubo. Language primitives and type disciplines for structured communication-based programming. In ESOP’98, volume 1381 of LNCS, pages 22–138. Springer-Verlag, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. K. Honda, N. Yoshida, and M. Carbone. Multiparty Asynchronous Session Types. In POPL’08, pages 273–284. ACM, 2008. A full version in JACM: 63(1-9):1–67, 2016. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. H. Hüttel, I. Lanese, V. T. Vasconcelos, L. Caires, M. Carbone, P.-M. Deniélou, D. Mostrous, L. Padovani, A. Ravara, E. Tuosto, H. T. Vieira, and G. Zavattaro. Foundations of session types and behavioural contracts. ACM Comput. Surv., 49(1):3:1–3:36, Apr. 2016. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. A. Igarashi and N. Kobayashi. A generic type system for the picalculus. Theor. Comput. Sci., 311(1-3):121–163, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. N. Kobayashi. Type-based information flow analysis for the picalculus. Acta Inf., 42(4-5):291–347, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. N. Kobayashi. A new type system for deadlock-free processes. In CONCUR’06, volume 4137 of LNCS, pages 233–247, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. N. Kobayashi and D. Sangiorgi. A hybrid type system for lockfreedom of mobile processes. TOPLAS, 32(5):16:1–16:49, May 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. N. Kobayashi, K. Suenaga, and L. Wischik. Resource usage analysis for the p-calculus. Logical Methods in Computer Science, 2(3), 2006.Google ScholarGoogle Scholar
  27. J. Lange, N. Ng, B. Toninho, and N. Yoshida. Full version of this paper. Available at https://arxiv.org/abs/1610.08843.Google ScholarGoogle Scholar
  28. J. Lange, E. Tuosto, and N. Yoshida. From Communicating Machines to Graphical Choreographies. In S. K. Rajamani and D. Walker, editors, POPL’15, pages 221–232. ACM Press, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. R. Milner. A Calculus of Communicating Systems, volume 92 of Lecture Notes in Computer Science. Springer, Berlin, 1980. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. R. Milner. Communication and Concurrency. Prentice-Hall, Inc., Upper Saddle River, NJ, USA, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. R. Milner and D. Sangiorgi. Barbed bisimulation. In W. Kuich, editor, ICALP, volume 623 of LNCS, pages 685–695. Springer-Verlag, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. I. Moraru, D. G. Andersen, and M. Kaminsky. There is More Consensus in Egalitarian Parliaments. In SOSP’13, pages 358–372, New York, NY, USA, 2013. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. N. Ng and N. Yoshida. Static Deadlock Detection for Concurrent Go by Global Session Graph Synthesis. In CC 2016, pages 174–184. ACM, 2016. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. H. R. Nielson and F. Nielson. Higher-order concurrent programs with finite communication topology (extended abstract). In POPL ’94, pages 84–97. ACM, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. L. Padovani. Deadlock and Lock Freedom in the Linear π-Calculus. In T. A. Henzinger and D. Miller, editors, CSL-LICS’14, pages 72:1– 72:10. ACM Press, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Rob Pike. Go Concurrency Patterns, 2012.Google ScholarGoogle Scholar
  37. https://talks. golang.org/2012/concurrency.slide.Google ScholarGoogle Scholar
  38. Sameer Ajamni. Advanced Go Concurrency Patterns, 2013. https: //talk.golang.org/2013/advconc.slide.Google ScholarGoogle Scholar
  39. Sameer Ajmani. Go Concurrency Patterns: Pipelines and cancellation, 2014. https://blog.golang.org/pipelines.Google ScholarGoogle Scholar
  40. D. Sangiorgi and D. Walker. The π-Calculus: a Theory of Mobile Processes. Cambridge University Press, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. K. Stadmüller, M. Sulzmann, and P. Thiemann. Static Trace-Based Deadlock Analysis for Synchronous Mini-Go. In APLAS, 2016. to appear.Google ScholarGoogle ScholarCross RefCross Ref
  42. K. Takeuchi, K. Honda, and M. Kubo. An Interaction-based Language and its Typing System. In PARLE’94, volume 817 of LNCS, pages 398–413. Springer-Verlag, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. The Go Authors. Effective Go. https://golang.org/doc/ effective_go.html.Google ScholarGoogle Scholar
  44. B. Toninho, L. Caires, and F. Pfenning. Higher-order processes, functions, and sessions: A monadic integration. In ESOP’13, pages 350–369, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. B. Toninho, L. Caires, and F. Pfenning. Corecursion and nondivergence in session-typed processes. In TGC’14, pages 159–175, 2014.Google ScholarGoogle Scholar
  46. P. Wadler. Proposition as Sessions. In ICFP’12, pages 273–286, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. S. Weirich and B. Yorgey. Unbound library. https://hackage. haskell.org/package/unbound.Google ScholarGoogle Scholar

Index Terms

  1. Fencing off go: liveness and safety for channel-based programming

                      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

                      Full Access

                      PDF Format

                      View or Download as a PDF file.

                      PDF

                      eReader

                      View online with eReader.

                      eReader
                      About Cookies On This Site

                      We use cookies to ensure that we give you the best experience on our website.

                      Learn more

                      Got it!