Seeing issue with BIO_free call
"'Samiya Khanum' via openssl-users" <[email protected]> Fri, 19 Sep 2025 18:34:56 +0530
| Newsgroups | gmane.comp.encryption.openssl.user |
|---|---|
| Message-ID | <CADmX34pXqrV78wmcb1tUM+h+SvHWJ55eDrCHVeCZCWpfug_v7g@mail.gmail.com> |
Hi,
I'm encountering an issue with the `BIO_free` call in the following code
snippet.
When `sslCleanupTask` is triggered and `BIO_free` is called, we
occasionally receive data on `listen_s`. This subsequently causes a hang
because `BIO_do_accept` in `sslListenTask` is then called on a file
descriptor that has already been freed or closed by `BIO_free`.
Could you please explain why `listen_s` is set in `readfds` when `BIO_free`
is called?
I've attempted to set the `BIO_CLOSE` flag, but the issue persists.
Do we need to set any other APIs or flags to prevent this? Please note that
we are not initiating any connections here.
*sslListenTask()*
*{*
* BIO *ppBio = NULL;*
* if ((ppBio = BIO_new_accept("[::]:443")) == NULL)*
* {*
* BIO_free(ppBio);*
* return;*
* }*
* BIO_set_bind_mode(ppBio, BIO_BIND_REUSEADDR);*
* /* First call sets up the BIO listening socket */*
* if (BIO_do_accept(ppBio) <= NULL)*
* {*
* BIO_free(ppBio);*
* return;*
* }*
* if( (listen_s = BIO_get_fd(ppBio,0)) <=0 )*
* {*
* BIO_free(ppBio);*
* return;*
* }*
* /**
* ** Loop waiting for SSLT connections*
* */*
* while (1)*
* {*
* fd_set readfds;*
* struct timeval tmout;*
* int num,max_fd;*
* tmout.tv_sec = 3;*
* tmout.tv_usec = 0;*
* FD_ZERO(&readfds);*
* FD_SET(listen_s,&readfds);*
* max_fd = listen_s;*
* num = select(max_fd + 1, &readfds, NULL, NULL, &tmout);*
* if (num <= 0)*
* {*
* if (!((num < 0) && (EINTR == errno)))*
* {*
* /* Set cancellation point for timeout and other errors except
EINTR */*
* pthread_testcancel();*
* }*
* continue;*
* }*
* if (FD_ISSET(listen_s, &readfds))*
* {*
* if (BIO_do_accept(rdy_acc) <= L7_NULL)*
* {*
* //err*
* }*
* client = BIO_pop(rdy_acc);*
* //Rest of the program for SSL*
* } *
* } /* while */*
*}*
*There is one more task doing the BIO_free if the SSL port changes.*
*sslCleanupTask()*
*{*
* BIO_free(ppBio);*
*}*
Thanks & Regards,
Samiya khanum
--
You received this message because you are subscribed to the Google Groups "openssl-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openssl-users+unsubscribe-MCmKBN63+Bmbup2nOX2J7Q@public.gmane.org
To view this discussion visit https://groups.google.com/a/openssl.org/d/msgid/openssl-users/CADmX34pXqrV78wmcb1tUM%2Bh%2BSvHWJ55eDrCHVeCZCWpfug_v7g%40mail.gmail.com.
smime.p7s
(application/pkcs7-signature, 4.1 KB) - not displayed