Company
Date Published
Author
Mike Heffner
Word count
2434
Language
English
Hacker News points
2

Summary

"At Netlify, we've been expanding our adoption of Go-based services for the backend infrastructure that powers our core services. We encountered a CGO crash in production while scaling our service to handle new traffic patterns. The fault was identified as coming from the libredirect library used for redirect parsing, which is wrapped with a C++ smart pointer. After adapting an exhaustive integration testing framework and running stress tests, we were able to reproduce the segfault and identify a race condition triggered by the shared pointers in the CGO bindings. We fixed this issue by changing the return type of the Parse function from 'redirects.Matcher' to '*redirects.Matcher', ensuring that the struct was not deallocated prematurely. The change prevented the segfault, and we were able to safely return to production."