Abstract:The Go programming language, also known as Golang, has become popular with developers in recent years due to its simple syntax, native support for concurrency, and automatic memory management. This language expects that developers do not need to know whether variables or objects are allocated on the stack or in the heap. The escape analysis of the Go compiler determines the allocation location, and then the garbage collector automatically recycles unreachable heap objects. Go’s escape analysis must correctly determine the allocation location of the object to ensure the memory state correctness. However, escape analysis related problems frequently occur in the Go community at present, potentially causing fatal problems such as program crashes, and there is currently a lack of research on this aspect. To effectively detect whether the code generated by the compiler has illegal memory references that may cause runtime crashes and fill the research gap, this study conducts abstract modeling on the Go program and proposes two rules for verifying the validity of store instructions. Based on these two rules, it overcomes the challenges of lacking high-level semantics in Go binaries and inconvenient access to runtime information and designs a lightweight analysis tool DBI-Go. DBI-Go adopts static analysis plus dynamic binary instrumentation and is implemented based on Pin, a dynamic binary analysis framework. Meanwhile, DBI-Go can identify illegal store instructions in Go binaries. Evaluation results show that DBI-Go can detect all known escape-related issues in the Go community, and also discover an issue that is previously unknown to the Go community. Finally, this issue has been confirmed. The applications in actual projects show that DBI-Go can assist developers in finding bugs in escape analysis algorithms. Evaluation results also show that the measures adopted by DBI-Go can reduce the false positive rate, and the extra runtime overhead brought by DBI-Go in 93.3% of the cases is less than twice the original. Additionally, DBI-Go can be adapted to different versions of Go without modifying Go’s compilation and runtime, therefore yielding wide applicability.