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

Memory leak in readable-stream when sending packets #1000

Closed
IceTank opened this issue May 18, 2022 · 4 comments
Closed

Memory leak in readable-stream when sending packets #1000

IceTank opened this issue May 18, 2022 · 4 comments

Comments

@IceTank
Copy link
Contributor

IceTank commented May 18, 2022

[x] The FAQ doesn't contain a resolution to my issue

Versions

  • minecraft-protocol: latest
  • server: vanilla/spigot/paper 1.12.2
  • node: 14.x

Detailed description of a problem

Writing packets on a nmp server can cause a memory leak the serializer. This is what my heap looks like after running out off memory

Object×979172 2 54 545 95253 % 85 308 40082 %  
Client×3 9 6720 % 72 301 20870 %  
Client@1661959 15 2240 % 52 042 94850 %  
serializer::Serializer@1666511 16 1280 % 49 284 12048 %  
_writableState::WritableState@1949265 17 2400 % 49 282 96048 %  
bufferedRequest::Object@1765163 18 640 % 49 282 34448 %  
next::Object@1764833 19 640 % 49 282 12848 %  
next::Object@1764837 20 640 % 49 281 91248 %  
next::Object@1764767 21 640 % 49 281 69648 %  
next::Object@1763723 22 640 % 49 281 48048 %  
next::Object@1763727 23 640 % 49 281 26448 %

image

The next go on for some time as they represent the queued up data in the Transform that is causing the memory leak.

I am not sure what might be causing this. But I think this is caused by protodef trying to parse invalid packets and failing. I had a similar issue in mineflayer where nmp would completely brick itself when it was trying to send invalid sign update packets. My guess is that something messes up causing the internal logic to break so packets are not parsed correctly and end up clogging up the buffer with garbage data.

Expected behavior

No memory leak

@extremeheat
Copy link
Member

How long does it take to get this error & what server is it on?

Did you dump the raw inbound packets also? This will make it easier to debug

@IceTank
Copy link
Contributor Author

IceTank commented Jun 4, 2022

How long does it take to get this error & what server is it on?

Did you dump the raw inbound packets also? This will make it easier to debug

This happened after about 8-12 hours. The server is 2b2t. I think this might have something to do with the fact that that server sends a login packet after you left the queue to log you in to the main server. My guess is that there is something somewhere not realizing that some destination is unavailable anymore. I was not able to reproduce this issue with local test yet. So it might be my code that is wrong?

@extremeheat
Copy link
Member

So it might be my code that is wrong?

Yes probably if you cannot reproduce with a basic code sample

@IceTank
Copy link
Contributor Author

IceTank commented Jul 8, 2022

I never really found what was causing this but I am 80% sure that it was some weird interaction with an infinity loop I had in my code that was blocking the event loop

@IceTank IceTank closed this as completed Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants