Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error during select (9): `Bad file descriptor' #50

Open
Al-Muhandis opened this issue Nov 15, 2023 · 4 comments
Open

Error during select (9): `Bad file descriptor' #50

Al-Muhandis opened this issue Nov 15, 2023 · 4 comments
Labels
question Further information is requested

Comments

@Al-Muhandis
Copy link
Contributor

Al-Muhandis commented Nov 15, 2023

What kind of bug could it be? Where can I find information?

[EBrookHTTPServer] Error during select (9): `Bad file descriptor'

Second error (other times):

Fatal error in GNU libmicrohttpd /root/libsagui-3.4.1/lib/libmicrohttpd-0.9.76/src/microhttpd/daemon.c:3845: Close socket failed.

I localized an interesting point. The error sometimes occurs if the FCL httpclient is used in one of the worker threads. If the client in the thread does not cause such errors never occurs

Thanks

@Al-Muhandis Al-Muhandis added the question Further information is requested label Nov 15, 2023
@Al-Muhandis
Copy link
Contributor Author

If it helps. The error certainly happens only if there are requests to secure site addresses when using the FP HTTPClient client.

Occurs under heavy load, as I understand, because in other projects such problems are not observed.

The code inside cycle with bulk count of aDomainName

      aHTTP.AllowRedirect:=True;                    
      if aIsHTTPS then
        aProt:='https'
      else
        aProt:='http';
      s:=aProt+'://'+aDomainName;
      aHTTP.Get(s, aResponse);
      aCode:=aHTTP.ResponseStatusCode;          

If not IsHTTPS then it's ok . if IsHTTPS is set then at any random turn of the cycle (there is no specific domain name because of which this happens), the application crashes with the above system daemon error. The error catching is not helps: app crashs always after this

@Al-Muhandis
Copy link
Contributor Author

The place in the microhttpd library where this error supposedly occurs, judging by the logs. I guess it's a bug in this place:

#ifdef EPOLL_SUPPORT
 3849     if (0 != (daemon->options & MHD_USE_EPOLL))
 3850     {
 3851       if (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL))
 3852       {
 3853         EDLL_remove (daemon->eready_head,
 3854                      daemon->eready_tail,
 3855                      pos);
 3856         pos->epoll_state &=
 3857           ~((enum MHD_EpollState) MHD_EPOLL_STATE_IN_EREADY_EDLL);
 3858       }
 3859       if ( (-1 != daemon->epoll_fd) &&
 3860            (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EPOLL_SET)) )
 3861       {
 3862         /* epoll documentation suggests that closing a FD
 3863            automatically removes it from the epoll set; however,
 3864            this is not true as if we fail to do manually remove it,
 3865            we are still seeing an event for this fd in epoll,
 3866            causing grief (use-after-free...) --- at least on my
 3867            system. */

https://fossies.org/linux/libmicrohttpd/src/microhttpd/daemon.c

@silvioprog
Copy link
Member

Hey @Al-Muhandis, could you try again using Sagui 3.4.4?

@Al-Muhandis
Copy link
Contributor Author

Hey @Al-Muhandis, could you try again using Sagui 3.4.4?

Hi! Thanks. I will try!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants