LXGaming / Sledgehammer

Smashes the stupid out of the client & server.
Apache License 2.0
16 stars 5 forks source link

[astralsorcery] Server world first tick crash: `OutOfMemoryError: unable to create new native thread` #52

Open Krutoy242 opened 6 months ago

Krutoy242 commented 6 months ago

Can't launch server. Every time its launched it crashing with this stack trace:

java.lang.OutOfMemoryError: unable to create new native thread
    at java.lang.Thread.start0(Native Method)
    at java.lang.Thread.start(Thread.java:717)
    at hellfirepvp.astralsorcery.common.starlight.network.TransmissionChain.threadedBuildTransmissionChain(TransmissionChain.java:71)
    at hellfirepvp.astralsorcery.common.starlight.network.TransmissionWorldHandler.buildSourceNetworkThreaded(TransmissionWorldHandler.java:133)
    at hellfirepvp.astralsorcery.common.starlight.network.TransmissionWorldHandler.tick(TransmissionWorldHandler.java:75)
    at hellfirepvp.astralsorcery.common.starlight.network.StarlightTransmissionHandler.tick(StarlightTransmissionHandler.java:49)
    at hellfirepvp.astralsorcery.common.auxiliary.tick.TickManager.worldTick(TickManager.java:55)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_3206_TickManager_worldTick_WorldTickEvent.invoke(.dynamic)

Removing sledgehammer.conf file (this set all changes to 'false') fix and server can run again.

crash-2024-04-21_12.15.59-server.txt

LXGaming commented 6 months ago

Interesting, I don't know why it would be throwing an OutOfMemoryError especially as according to the crash report it's only allocated 2392 MB out of 5120 MB of memory, could you please try replacing -Xms2G with -Xms5G in your JVM Flags and see if the issue still occurs.

Could you please attach your debug.log (preferred) or latest.log file.

LXGaming commented 6 months ago

I can't reproduce this issue on Windows even when using -Xms1G -Xmx1G so I don't believe it's a memory issue, as you're running Linux I suggest investigating how many threads Java is creating as it may be exceeding limits

https://stackoverflow.com/questions/16789288/java-lang-outofmemoryerror-unable-to-create-new-native-thread

Krutoy242 commented 6 months ago

I cannot reproduce this issue anymore. Seems like it happens on random or somehow related to world or crash reason.

What i know so far:

There is debug.log of fine running server, with all config options enabled and xms is 2G as usual debug.log

Krutoy242 commented 6 months ago

I suggest investigating how many threads Java is creating as it may be exceeding limits

Since this issue happens only with Sledge Hammer enabled, could you tell me what exact config option i should disable to fix that? I have only 25 enabled features and i want to keep ones that not causing this crash.

LXGaming commented 6 months ago

Try turning off flush-network-on-tick as that patch does create a Thread.

If you do reproduce the issue please provide the debug.log for that run as the OutOfMemoryError could be the result of another error occurring.

I'm assuming you're running docker due to the path /home/container/ in the debug.log, given that this issue is random I'm wondering if it's occurring when the host is under heavy load, I suggest running ulimit -a on the host and inside of a container and note the max user processes value, I believe that this issue is caused by lack of system resources rather than a Sledgehammer issue.

Krutoy242 commented 6 months ago

Then, i will wait until this crash happens again and provide more logs. I will try to test disabling flush-network-on-tick when this happens.

I suggest running ulimit -a

I cannot run that since I only have access to Pterodactyl control panel. Same, Ptero doesnt give access to max user processes values.

LXGaming commented 6 months ago

Oh, If it's a shared host then you might want to contact your server provider about the issue.

Krutoy242 commented 6 months ago

I would better just disable erroring SledgeHammer features rather than mess with server provider 😅 Also, there was other E2EE players who reported similar issue, so i believe this caused by mods rather than hardware.