Go Back   EQEmulator Home > EQEmulator Forums > Archives > Archive::Development > Archive::Bugs

Archive::Bugs Archive area for Bugs's posts that were moved here after an inactivity period of 90 days.

Reply
 
Thread Tools Display Modes
  #1  
Old 11-13-2003, 03:13 PM
kate
Fire Beetle
 
Join Date: Nov 2002
Posts: 10
Default 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.
Reply With Quote
  #2  
Old 11-13-2003, 03:52 PM
Edgar1898
Senior Member
Former EQEmu Developer
Current EQ2Emu Lead Developer
 
Join Date: Dec 2002
Posts: 1,065
Default

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)
__________________
Lethal Encounter
Reply With Quote
  #3  
Old 11-13-2003, 05:16 PM
kate
Fire Beetle
 
Join Date: Nov 2002
Posts: 10
Default 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.
Reply With Quote
  #4  
Old 11-13-2003, 05:24 PM
Edgar1898
Senior Member
Former EQEmu Developer
Current EQ2Emu Lead Developer
 
Join Date: Dec 2002
Posts: 1,065
Default

yup that works fine
__________________
Lethal Encounter
Reply With Quote
  #5  
Old 11-13-2003, 06:57 PM
kathgar
Discordant
 
Join Date: May 2002
Posts: 434
Default

safe_delete_array()?
__________________
++[>++++++<-]>[<++++++>-]<.>++++[>+++++<-]>[<
+++++>-]<+.+++++++..+++.>>+++++[<++++++>-]<+
+.<<+++++++++++++++.>.+++.------.--------.>+.
Reply With Quote
  #6  
Old 11-13-2003, 11:24 PM
Trumpcard
Demi-God
 
Join Date: Jan 2002
Location: Charlotte, NC
Posts: 2,614
Default

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.
__________________
Quitters never win, and winners never quit, but those who never win and never quit are idiots.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 11:46 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3