The version in the Kent Academic Repository may differ from the final published version. Users are advised to check http://kar.kent.ac.uk for the status of the paper. Users should always cite the published version of record.
This paper describes a static verification framework for the message-passing fragment of the Go programming language. Our framework extracts models that over-approximate the message-passing behaviour of a program. These models, or behavioural types, are encoded in Promela, hence can be efficiently verified with Spin. We improve on previous works by verifying programs that include communication-related parameters that are unknown at compile-time, i.e., programs that spawn a parameterised number of threads or that create channels with a parameterised capacity. These programs are checked via a bounded verification approach with bounds provided by the user.
The Go programming language offers a wide range of primitives to coordinate lightweight threads, e.g., channels, waitgroups, and mutexes -all of which may cause concurrency bugs. Static checkers that guarantee the absence of bugs are essential to help programmers avoid these costly errors before their code is executed. However existing tools either miss too many bugs or cannot handle large programs. To address these limitations, we propose a static checker for Go programs which relies on performing bounded model checking of their concurrent behaviours. In contrast to previous works, our approach deals with large codebases, supports programs that have statically unknown parameters, and is extensible to additional concurrency primitives. Our work includes a detailed presentation of the extraction algorithm from Go programs to models, an algorithm to automatically check programs with statically unknown parameters, and a large scale evaluation of our approach. The latter shows that our approach outperforms the state-of-the-art. 1 func preload(trees []string, n int) { 2 ch := make(chan string, n) // new chan with capacity n 3 limitCh := make(chan int, runtime.NumCPU()) 4 for i := 0; i < runtime.NumCPU(); i++ { 5 limitCh <-1 // send token on chan limitCh 6 } 7 var wg sync.WaitGroup 8 for _, t := range trees { 9 wg.Add(1) // increment wg counter 10 go func(v string) { // spawn goroutine 11 <-limitCh // receive token before starting work 12 s := DoSomeWork(v) 13 ch <-s 14 limitCh <-1 // return token 15 wg.Done() // decrement wg counter 16 }(t) 17 } 18 go func() { // spawn goroutine 19 wg.Wait() // wait for wg to reach 0 20 close(ch) // set ch to closed 21 }() 22 for s := range ch { // receive message from ch 23 if IsError(s) { 24
scite is a Brooklyn-based organization that helps researchers better discover and understand research articles through Smart Citations–citations that display the context of the citation and describe whether the article provides supporting or contrasting evidence. scite is used by students and researchers from around the world and is funded in part by the National Science Foundation and the National Institute on Drug Abuse of the National Institutes of Health.