Jump to content

  •  

Bug Tracker Migration

June 3rd
Good news everyone! The staff has decided that it is time to slowly kill off this Bug Tracker. We will begin the process of slowly migrating from this Bug Tracker over to our Github Issues which can be found here: https://github.com/HerculesWS/Hercules/issues

Over the next couple of days, I will be closing off any opportunity to create new reports. However, I still will keep the opportunity to reply to existing Bug Reports. Doing this will allow us to slowly fix any bug reports we have listed here so that we can easily migrate over to our Issue Tracker.

Update - June 7th 2015: Creating new bug posts has been disabled. Please use our https://github.com/HerculesWS/Hercules/issues tracker to post bugs. Users are still able to reply to existing bug posts.

- Administration

Issue Information

  • #004856

  • 5 - Critical

  • Fixed

Issue Confirmations

  • Yes (0)No (0)
Photo

send shortlist corrupts memory

Posted by Hercules Bot on 08 April 2011 - 06:47 PM

Originally posted by Ai4rei
http://www.eathena.w...er&showbug=4856

Originally reported in Map server crash

In an environment, where the amount of simultanously connected clients aproaches FD_SETSIZE a memory corruption occurs due yet unknown reason. To reproduce with sane dimensions (how it is currently being done):
  • Compile servers with enabled shortlists (default) and FD_SETSIZE=1024 (windows), also tested with debian, where system FD_SETSIZE is also around this value.
  • Start up server and connect 1000 clients.
  • Disconnect all clients at once.
  • The server fatal errors on select (windows, "socket functions used on something, that is not a socket") or segfaults in send_shortlist_do_sends due to invalid fd used with session[] (linux).


Workarounds:
Workaround for this issue is currently to increase FD_SETSIZE or disable SEND_SHORTLIST.

Cause:
The defect is in send_shortlist_do_sends on line:
CODE
memset(send_shortlist_set, 0, sizeof(send_shortlist_set));

this wipes all bits, that indicate that a fd is already on the list. While this would work if the list was not changed through send_shortlist_add_fd until send_shortlist_do_sends exits, calls to socket's func_send can cause set_eof, which adds fds to the shortlist. send_shortlist_add_fd does not recognize, that the fd is potentially still in the array, thus adds a copy of it. This way send_shortlist_array grows, until it overflows FD_SETSIZE starting to corrupt memory around and depending on platform causing other side effects.

Possibly Related Bugreports:
bugreport:4646
bugreport:3504
bugreport:2475

This post has been edited by Ai4rei: Apr 8 2011, 08:33 PM