On Sun, Mar 3, 2024 at 1:25 PM Evgeny Chormonov <en.chormo...@gmail.com> wrote: > > I noticed that ASAN checker in the Go source code is defined using CGO > https://github.com/golang/go/blob/master/src/runtime/asan/asan.go > But the C ASAN functions are called from the Go runtime using assembly code > instead of a common CGO call. > https://github.com/golang/go/blob/master/src/runtime/asan_amd64.s#L36 > > This discovery has sparked my interest, and I am curious to know if I can > employ a similar method to execute my own C functions from my Go code. Could > you clarify if this is a viable option?
Viable is in the eyes of the beholder. You can use a similar method. But you have to hand-write the assembler code for each C function you want to call. And if the C function ever blocks on, say, network I/O, your entire Go program can hang unexpectedly. We only use this technique for ASAN because we have a very limited number of functions to call, and we know for sure that those functions can never block. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcVQ9zZaggpik5tu%3DvgYucUWXY57K601-a%3D6d4SXg_kidQ%40mail.gmail.com.