PlusEMU Crash after 10-15 minutes

Blasteh

Lord Farquaad
Apr 3, 2013
1,151
513
Hi,
Out of no where my emulator started crashing, no changes have been made to the database recently but it is throwing a few errors.

I'm not sure if it's because of the "System.OutOfMemoryException" or not, but here's this log.
Code:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Plus.Messages.Net.GamePacketParser.handlePacketData(Byte[] Data) in C:\Users\Administrator\Desktop\Emulator\Messages\Net\GamePacketParser.cs:line 75
Date/Time: 2018-02-08 13:27:05,435
Thread: 25
Packet Error!

System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at Plus.Communication.Packets.Incoming.ClientPacket.ToString()
   at Plus.HabboHotel.GameClients.GameClient.parser_onNewPacket(ClientPacket Message)
   at Plus.Messages.Net.GamePacketParser.handlePacketData(Byte[] Data)

There's also another error in packeterrors.txt
Code:
Error in packet [1848] BODY: [0]#?[0]:w=19,0 l=7,744 r:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Plus.Communication.Packets.Outgoing.ServerPacket.WriteString(String s) in C:\Users\Administrator\Desktop\Emulator\Communication\Packets\Outgoing\ServerPacket.cs:line 70
   at Plus.Communication.Packets.Outgoing.Rooms.Engine.ItemUpdateComposer.WriteWallItem(Item Item, Int32 UserId) in C:\Users\Administrator\Desktop\Emulator\Communication\Packets\Outgoing\Rooms\Engine\ItemUpdateComposer.cs:line 22
   at Plus.Communication.Packets.Outgoing.Rooms.Engine.ItemUpdateComposer..ctor(Item Item, Int32 UserId) in C:\Users\Administrator\Desktop\Emulator\Communication\Packets\Outgoing\Rooms\Engine\ItemUpdateComposer.cs:line 15
   at Plus.Communication.Packets.Incoming.Rooms.Engine.MoveWallItemEvent.Parse(GameClient Session, ClientPacket Packet) in C:\Users\Administrator\Desktop\Emulator\Communication\Packets\Incoming\Rooms\Engine\MoveWallItemEvent.cs:line 39
   at Plus.Communication.Packets.PacketManager.TryExecutePacket(GameClient Session, ClientPacket Packet) in C:\Users\Administrator\Desktop\Emulator\Communication\Packets\PacketManager.cs:line 160
   at Plus.HabboHotel.GameClients.GameClient.parser_onNewPacket(ClientPacket Message) in C:\Users\Administrator\Desktop\Emulator\HabboHotel\GameClients\GameClient.cs:line 74

Other than those two/three errors, there's nothing else indicating the crash.

EDIT: The emulator crashed but didn't throw an error when I had the text files open... It didn't ask me to reload the text files.
 
Last edited:

Mythic

Member
Jan 27, 2018
33
15
Please give us the specs of your system on which the Emulator is running.
How many users use your hotel in the time the emulator is running? Or is it crashing even when 0 users use it?

Out Of Memory Exception is the error which causes the crash. Please give us also details which PlusEMU Release your are using.
 

Blasteh

Lord Farquaad
Apr 3, 2013
1,151
513
Please give us the specs of your system on which the Emulator is running.
How many users use your hotel in the time the emulator is running? Or is it crashing even when 0 users use it?

Out Of Memory Exception is the error which causes the crash. Please give us also details which PlusEMU Release your are using.
It has enough RAM, it ran smoothly before. It crashes whenever there's 0 people online.

Also, it's not exactly PlusEMU, most of it is recoded but it's base is Plus, so telling you the release is impossible and wont help.
 

Mikee

Active Member
Jul 8, 2017
162
102
Code:
at Plus.Communication.Packets.Incoming.ClientPacket.ToString()

So here's the problem.
Some packet is being passed from the client to the emulator. This packet then is getting converted here .ToString() as you can see.
But for some reason, when the packet gets converted ToString, the packet is so large that the string object in c# can't allocate enough space for it; hence the memory exception.

My recommendation:
Change to a 64bit OS if you're not already on one.
Or find the packet that's getting converted this way, and make sure it gets handled properly so this error doesn't occur.

I specifically recommend wrapping this line
Code:
Plus.Communication.Packets.Incoming.ClientPacket.ToString()
in a try{}catch block and trying to parse the clientpacket to a string, and catching for the memory exception that you get, that way the packets that are too large won't crash the emulator but they will be ignored and not pass through.

Goodluck,
 
Last edited:

Blasteh

Lord Farquaad
Apr 3, 2013
1,151
513
Code:
at Plus.Communication.Packets.Incoming.ClientPacket.ToString()

So here's the problem.
Some packet is being passed from the client to the emulator. This packet then is getting converted here .ToString() as you can see.
But for some reason, when the packet gets converted ToString, the packet is so large that the string object in c# can't allocate enough space for it; hence the memory exception.

My recommendation:
Change to a 64bit OS if you're not already on one.
Or find the packet that's getting converted this way, and make sure it gets handled properly so this error doesn't occur.

I specifically recommend wrapping this line
Code:
Plus.Communication.Packets.Incoming.ClientPacket.ToString()
in a try{}catch block and trying to parse the clientpacket to a string, and catching for the memory exception that you get, that way the packets that are too large won't crash the emulator but they will be ignored and not pass through.

Goodluck,
Ah, thank you!

Testing out this code:
Code:
        public override string ToString()
        {
            try
            {

                var str = "[" + Header + "] BODY: " +
                   (PlusEnvironment
                      .GetDefaultEncoding()
                      .GetString(Body)
                      .Replace(Convert.ToChar(0).ToString(), "[0]"));

                // return if no exception is thrown
                return str;
            }
            catch (Exception e)
            {
                return e.Message;
            }
        }
 
Update: When placing 20+ soccer balls in one spot in a room, and a user steps on them to kick them it caused it to lag and crash, with the code replacement, it fixed it but still causes lag, but not sure if there's anyway to fix that. Maybe limit the number of soccer balls to a room?
 

Mikee

Active Member
Jul 8, 2017
162
102
Hard for me to gauge exactly since I don't know whats happening when, and what the full code is from the stack trace but my original thoughts were this.

Instead of try{}catch{} within the ToString method (never new sled coded one that inherited from the original one, pretty neat) but wrap a try{}Catch{} around the ToString line of code, then when you catch for an exception just pass through it, i.e. reassign
Code:
Plus.Communication.Packets.Incoming.ClientPacket
to null, and then return;
Also use
Code:
catch(OutOfMemoryException e){
//Log it
Plus.Communication.Packets.Incoming.ClientPacket = null;
return;
}

instead of
catch(Exception e){}

Just bad practice and could cause issues later.

Again, hard for me to make a good judgement call without more info.
Let me know how it goes,
 

Users who are viewing this thread

Top