On Mon, Dec 2, 2024 at 9:32 AM Lealem Amedie <lealemt...@gmail.com> wrote:
>
> I’m trying to get an https server working by overwriting the 
> accept/read/write methods in the http module. I’m using go-wolfssl for TLS.
>
> The server will accept a TLS 1.2 connection, then send some random data to 
> the client connects, then wait for another connection.
>
> The issue that I’m seeing is that whenever the server sends large payloads, 
> it’ll do that successfully but it then can’t send data to the next client 
> that connects (the send errors out with the TCP error EBADF). If dealing with 
> smaller payloads (<30k), the server can send data successfully to each client 
> that connects. Then as soon as a large one is sent, the next transmission 
> fails.
>
> If I disable the GOGC with debug.SetGCPercent(-1), the issue goes away and I 
> can send as many large payloads as required. From the debugging I’ve done so 
> far, this looks like an issue with the GO garbage collector dropping C 
> pointers. go-wolfssl relies on the wolfSSL C library so it uses CGO. Does 
> anyone have any other ideas or input?
>
> Code is below. See this repo to actually run it GitHub - 
> lealem47/go-wolfssl-https-server

If the program uses cgo, and the problem is fixed by disabling the
garbage collector, then it is most likely the case that the cgo code
is not following the rules described at
https://pkg.go.dev/cmd/cgo#hdr-Passing_pointers.  You could try
setting GOEXPERIMENT=cgocheck2 in the environment when building the
program; that will enable stricter checks of cgo pointers, though it
still won't catch all possible misuses in the C code.

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/CAOyqgcVEMsv%3DLGXna6tR0AAtRr6615YtzqYN5g1wnwOgEg_TGA%40mail.gmail.com.

Reply via email to