On Mon, Dec 2, 2024 at 11:16 AM Jason E. Aten <j.e.a...@gmail.com> wrote: > > ChatGPT seems to think that the go-wolfssl library is not following proper > CGO rules in > many places. The transcript below is long. I post it nonetheless, in case > such > analysis is new for readers. I would suggest that you (everyone) can and > should > be doing this kind of "code review by LLM" yourself to quickly resolve > these kinds of issues. Also, it might be wrong!?! since it comes from an LLM. > But at least we can talk about specific code snippets now. > > Transcript using ChatGPT 4o from Github copilot: > > @workspace I suspect there are one or more bugs in the use of CGO in this > this Go library, go-wolfssl. That is, I suspect that the CGO rules for > passing C pointers back and forth between Go and C threads are not being > followed, and this is causing bugs in the use of the library. Please audit > all the Go and C files in this workspace, and point out places where the CGO > pointer rules are not being followed. > > Workspace: In CGO, there are strict rules for passing pointers between Go and > C. Specifically, Go pointers should not be passed to C code, and C pointers > should not be used in Go code without proper conversion. Here are some > potential violations of these rules in your workspace: > > 1. **`random.go`**: > ```go > func Wc_RNG_GenerateBlock(rng *C.struct_WC_RNG, b []byte, sz int) int { > return int(C.wc_RNG_GenerateBlock(rng, > (*C.uchar)(unsafe.Pointer(&b[0])), C.word32(sz))) > } > ``` > - The Go slice > > b > > is being converted to a C pointer and passed to the C function. This is a > violation of the CGO rules.
This code is in itself fine, and is a typical example of using cgo. I didn't read any further. 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 visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcX4a9AAA_btAsjF5AVheOaddQrqKsVnCN%2BM7v2rbwq2cg%40mail.gmail.com.