EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Archive::Bugs (https://www.eqemulator.org/forums/forumdisplay.php?f=622)
-   -   ZSList::SendWhoAll, wold server related crash bug FIX (https://www.eqemulator.org/forums/showthread.php?t=10220)

kate 11-13-2003 03:13 PM

ZSList::SendWhoAll, wold server related crash bug FIX
 
Ok, after a little debugging, I think I got a fix.

The bug seems to be a linux only problem cased by people doing alot of /who all commands.

Ok, the file is world/zoneserver.cpp

function is: ZSList::SendWhoAll

ok here is the fix:

scroll down till you see this:
Code:

        int32 unknown52=totalusers;
        int32 unknown56=1;
        ServerPacket* pack2 = new ServerPacket(0x2010,64+totallength+(49*totalusers));
        char *buffer=(char*)malloc(pack2->size);
        char *bufptr=buffer;
        memset(buffer,0,pack2->size);
        memcpy(bufptr,&plid, sizeof(int32));

ok, the change starts with:
char *buffer=(char*)malloc(pack2->size);

make it read:
Code:

        int32 unknown52=totalusers;
        int32 unknown56=1;
        ServerPacket* pack2 = new ServerPacket(0x2010,64+totallength+(49*totalusers));
 //      char *buffer=(char*)malloc(pack2->size);
        uchar buffer[pack2->size]; // added line
        uchar *bufptr=buffer; // changed line
        memset(buffer,0,pack2->size);

Then at the end of the function you see:
Code:

        safe_delete(pack2);
        free(buffer);
        safe_delete(output);
}

and comment out the free line.
should like like this:
Code:

        safe_delete(pack2);
//      free(buffer);
        safe_delete(output);
}

Anyway, I have this running on the stormweavers server with no problems, let me know how the rest of you do.

This fix should work under windows as well, though at this point in time that has not been tested.

Edgar1898 11-13-2003 03:52 PM

that wont work under any true c++ compiler because arrays such as that must be declared with a constant size. VS .NET will not allow it.

Example:


Quote:

<kathgar> #include <iostream>
<kathgar> #include <string>
<kathgar> using namespace std;
<kathgar> int main()
<kathgar> {
<kathgar> int b;
<kathgar> cin >> b;
<kathgar> char buffer[b];
<kathgar> for(int x = 0; x < b; x++)
<kathgar> buffer[x] = 'A';
<kathgar> for(int x = 0; x < b; x++)
<kathgar> cout << buffer[x];
<kathgar> cout << ' ';
<kathgar> cout << sizeof(buffer) << endl;
<kathgar> return 0;
<kathgar> }
<kathgar> kathgar@enigma-interactive:~$ g++ -o buffer buffer.cpp
<kathgar> kathgar@enigma-interactive:~$
compiled fine with a standard c compiler, but not with a true C++ compiler:

Code:

c:\test\blah.cpp(8): error C2057: expected constant expression
c:\test\blah.cpp(8): error C2466: cannot allocate an array of constant size 0
c:\test\blah.cpp(8): error C2133: 'buffer' : unknown size
c:\test\blah.cpp(14): error C2070: 'char []': illegal sizeof operand

(Same program in VS)

kate 11-13-2003 05:16 PM

Updated Fix
 
Ok, you may be right, but I found a way that works.

insited of using:
Code:

char *buffer=(char*)malloc(pack2->size);
use:
Code:

uchar *buffer = new uchar[pack2->size];
That is a more currect C++ way of doing it then even using malloc.

then under that line change:
Code:

char *bufptr=buffer;
to:
Code:

uchar *bufptr=buffer;
Then at the end of the function change:
Code:

free(buffer);
Over to:
Code:

safe_delete(buffer);
Anyway, that works under linux and windows, and still seems to fix the crash bug, good luck.

Edgar1898 11-13-2003 05:24 PM

yup that works fine

kathgar 11-13-2003 06:57 PM

safe_delete_array()?

Trumpcard 11-13-2003 11:24 PM

yea, buffer is an array, not a single object, so it needs to be delete [] or safe_delete_array.
Safe delete is our choice, we went back a couple of months ago and tried to convert all deletes to safe deletes..

That and other changes are available in CVS today.

Also, kath corrected a potenial crash bug in world server as well.


All times are GMT -4. The time now is 04:48 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.