Skip to main content

2020 | OriginalPaper | Buchkapitel

Finding and Fixing a Mismatch Between the Go Memory Model and Data-Race Detector

A Story on Applied Formal Methods

verfasst von : Daniel Schnetzer Fava

Erschienen in: Software Engineering and Formal Methods

Verlag: Springer International Publishing

Aktivieren Sie unsere intelligente Suche, um passende Fachinhalte oder Patente zu finden.

search-config
loading …

Abstract

Go is an open-source programming language developed at Google. In previous works, we presented formalizations for a weak memory model and a data-race detector inspired by the Go specification. In this paper, we describe how our theoretical research guided us in the process of finding and fixing a concrete bug in the language. Specifically, we discovered and fixed a discrepancy between the Go memory model and the Go data-race detector implementation—the discrepancy led to the under-reporting of data races in Go programs. Here, we share our experience applying formal methods on software that powers infrastructure used by millions of people.

Sie haben noch keine Lizenz? Dann Informieren Sie sich jetzt über unsere Produkte:

Springer Professional "Wirtschaft+Technik"

Online-Abonnement

Mit Springer Professional "Wirtschaft+Technik" erhalten Sie Zugriff auf:

  • über 102.000 Bücher
  • über 537 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Maschinenbau + Werkstoffe
  • Versicherung + Risiko

Jetzt Wissensvorsprung sichern!

Springer Professional "Technik"

Online-Abonnement

Mit Springer Professional "Technik" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 390 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Maschinenbau + Werkstoffe




 

Jetzt Wissensvorsprung sichern!

Springer Professional "Wirtschaft"

Online-Abonnement

Mit Springer Professional "Wirtschaft" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 340 Zeitschriften

aus folgenden Fachgebieten:

  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Versicherung + Risiko




Jetzt Wissensvorsprung sichern!

Anhänge
Nur mit Berechtigung zugänglich
Fußnoten
1
There are good reasons why a type checker cannot enforce such a discipline without seriously restricting the language.
 
2
The relation below can be derived by both program-order as well as by rule (I). Similar for the send and receive operations performed by T1.
$$\begin{aligned} c \leftarrow 0~\text {by}~T0 ~~\sqsubset _{hb}~~ \mathop {\leftarrow c}{}~\text {by}~T0 \end{aligned}$$
.
 
3
In the implementation of the send operation, a message is moved from the sender’s buffer to a receiver’s buffer ep on line 16. The index c.sendx is incremented in line 19 and the increment wraps around based on the length of the array—lines 20 to 22. The number of elements in the array is incremented, the lock protecting the channel is unlocked and the function returns—lines 23 to 25.
 
4
The send operation by T0 is analogous to acquire and the receive to release.
 
5
Recall that the mutual exclusion and message passing patterns were introduced in Fig. 1 and discussed in Sect. 2.
 
7
The place-holder is a variable local to a function in TSan, as opposed to an extra memory region allocated in Go.
 
9
As noted in [5], “the interplay between forward and backward channels can also be understood as a form of flow control. Entries in the backward channel’s queue are not values deposited by threads. Instead, [these entries] can be seen as tickets that grant senders a free slot in the communication channel.”.
 
12
For example, the closing of channels in both  [4] and in Go cause happens-before information to be deposited onto the channel, regardless of whether the channel is full.
 
13
Our observation about the representational different between specification and implementation is not new. The idea of bridging specification and implementation has been tackled by many fronts, for example  [1].
 
14
Because of stigma, the “formal” qualifier has been de-emphasized when disseminating formal methods in industry  [13]. This stance has shifted dramatically  [3].
 
16
Because of differences in how vector clocks are allocated and managed, the memory gains reported by the reference data-race detector may be different from TSan’s.
 
Literatur
2.
Zurück zum Zitat Brewer, E.A.: Kubernetes and the path to cloud native. In: Ghandeharizadeh, S., Barahmand, S., Balazinska, M., Freedman, M.J. (eds.) Proceedings of the Sixth ACM Symposium on Cloud Computing, SoCC 2015, Kohala Coast, Hawaii, USA, August 27–29, 2015, p. 167. ACM (2015) Brewer, E.A.: Kubernetes and the path to cloud native. In: Ghandeharizadeh, S., Barahmand, S., Balazinska, M., Freedman, M.J. (eds.) Proceedings of the Sixth ACM Symposium on Cloud Computing, SoCC 2015, Kohala Coast, Hawaii, USA, August 27–29, 2015, p. 167. ACM (2015)
4.
Zurück zum Zitat Fava, D., Steffen, M., Stolz, V.: Operational semantics of a weak memory model with channel synchronization. J. Log. Algebr. Methods Program. 103, 1–30 (2019). An extended version of the FM 18 publication with the same titleMathSciNetCrossRef Fava, D., Steffen, M., Stolz, V.: Operational semantics of a weak memory model with channel synchronization. J. Log. Algebr. Methods Program. 103, 1–30 (2019). An extended version of the FM 18 publication with the same titleMathSciNetCrossRef
5.
Zurück zum Zitat Fava, D.S., Steffen, M.: Ready, set, Go! data-race detection and the Go language. Sci. Comput. Program. 195, 102473 (2020)CrossRef Fava, D.S., Steffen, M.: Ready, set, Go! data-race detection and the Go language. Sci. Comput. Program. 195, 102473 (2020)CrossRef
10.
Zurück zum Zitat Lamport, L.: Time, clocks, and the ordering of events in a distributed system. Commun. ACM 21(7), 558–565 (1978)CrossRef Lamport, L.: Time, clocks, and the ordering of events in a distributed system. Commun. ACM 21(7), 558–565 (1978)CrossRef
11.
Zurück zum Zitat Lattner, C., Adve, V.: LLVM: a compilation framework for lifelong program analysis & transformation. In International Symposium on Code Generation and Optimization, 2004, CGO 2004, pp. 75–86. IEEE (2004) Lattner, C., Adve, V.: LLVM: a compilation framework for lifelong program analysis & transformation. In International Symposium on Code Generation and Optimization, 2004, CGO 2004, pp. 75–86. IEEE (2004)
12.
Zurück zum Zitat Merkel, D.: Docker: lightweight Linux containers for consistent development and deployment. Linux J. 2014(239), 2 (2014) Merkel, D.: Docker: lightweight Linux containers for consistent development and deployment. Linux J. 2014(239), 2 (2014)
13.
Zurück zum Zitat Newcombe, C., Rath, T., Zhang, F., Munteanu, B., Brooker, M., Deardeuff, M.: How Amazon web services uses formal methods. Commun. ACM 58(4), 66–73 (2015)CrossRef Newcombe, C., Rath, T., Zhang, F., Munteanu, B., Brooker, M., Deardeuff, M.: How Amazon web services uses formal methods. Commun. ACM 58(4), 66–73 (2015)CrossRef
Metadaten
Titel
Finding and Fixing a Mismatch Between the Go Memory Model and Data-Race Detector
verfasst von
Daniel Schnetzer Fava
Copyright-Jahr
2020
DOI
https://doi.org/10.1007/978-3-030-58768-0_2