Paper: StackOverflow Error when using Block#setType() - Crashes server.

Created on 21 Apr 2019  路  6Comments  路  Source: PaperMC/Paper

Link/paste of stack trace

java.util.concurrent.CompletionException: java.lang.StackOverflowError
        at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273) ~[?:1.8.0_171]
        at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280) ~[?:1.8.0_171]
        at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:604) ~[?:1.8.0_171]
        at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577) ~[?:1.8.0_171]
        at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:442) ~[?:1.8.0_171]
        at com.google.common.util.concurrent.MoreExecutors$DirectExecutorService.execute(MoreExecutors.java:260) ~[patched_1.13.2.jar:git-Paper-621]
        at java.util.concurrent.CompletableFuture$UniCompletion.claim(CompletableFuture.java:529) ~[?:1.8.0_171]
        at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:599) ~[?:1.8.0_171]
        at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577) ~[?:1.8.0_171]
        at java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:617) ~[?:1.8.0_171]
        at java.util.concurrent.CompletableFuture.thenApplyAsync(CompletableFuture.java:1993) ~[?:1.8.0_171]
        at net.minecraft.server.v1_13_R2.Scheduler$a.a(SourceFile:147) ~[patched_1.13.2.jar:git-Paper-621]
        at java.util.Map.computeIfAbsent(Map.java:957) ~[?:1.8.0_171]
        at net.minecraft.server.v1_13_R2.Scheduler$a.a(SourceFile:137) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.Scheduler$a.a(SourceFile:143) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.ChunkStatus.a(SourceFile:105) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.ChunkStatus.a(SourceFile:22) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.Scheduler$a.a(SourceFile:143) ~[patched_1.13.2.jar:git-Paper-621]
        at java.util.Map.computeIfAbsent(Map.java:957) ~[?:1.8.0_171]
        at net.minecraft.server.v1_13_R2.Scheduler$a.a(SourceFile:137) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.Scheduler$a.a(SourceFile:143) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.ChunkStatus.a(SourceFile:105) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.ChunkStatus.a(SourceFile:22) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.Scheduler$a.a(SourceFile:143) ~[patched_1.13.2.jar:git-Paper-621]
        at java.util.Map.computeIfAbsent(Map.java:957) ~[?:1.8.0_171]
        at net.minecraft.server.v1_13_R2.Scheduler$a.a(SourceFile:137) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.Scheduler$a.a(SourceFile:143) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.ChunkStatus$1.a(SourceFile:53) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.ChunkStatus$1.a(SourceFile:27) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.Scheduler$a.a(SourceFile:143) ~[patched_1.13.2.jar:git-Paper-621]
        at java.util.Map.computeIfAbsent(Map.java:957) ~[?:1.8.0_171]
        at net.minecraft.server.v1_13_R2.Scheduler$a.a(SourceFile:137) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.Scheduler$a.a(SourceFile:143) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.ChunkStatus.a(SourceFile:105) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.ChunkStatus.a(SourceFile:22) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.Scheduler$a.a(SourceFile:143) ~[patched_1.13.2.jar:git-Paper-621]
        at java.util.Map.computeIfAbsent(Map.java:957) ~[?:1.8.0_171]
        at net.minecraft.server.v1_13_R2.Scheduler$a.a(SourceFile:137) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.Scheduler$a.a(SourceFile:143) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.ChunkStatus.a(SourceFile:105) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.ChunkStatus.a(SourceFile:22) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.Scheduler$a.a(SourceFile:143) ~[patched_1.13.2.jar:git-Paper-621]
        at java.util.Map.computeIfAbsent(Map.java:957) ~[?:1.8.0_171]
        at net.minecraft.server.v1_13_R2.Scheduler$a.a(SourceFile:137) ~[patched_1.13.2.jar:git-Paper-621]
        at net.minecraft.server.v1_13_R2.Scheduler$a.a(SourceFile:143) ~[patched_1.13.2.jar:git-Paper-621]

This stacktrace went on for hundreds of lines. This is just the begining of it.
I tried to download the entire log but my computer crashed it was so large. So if requested, I can try producing the entire stacktrace again.

Plugin list:

The plugin causing this is a custom plugin I am working on: It is a world generator.
This issue began to occur when I used Block#setType() within a BlockPopulator. The material type didn't change the outcome.

On some occasions, while I was testing the Block#setType() method worked inside the BlockPopulator without fail. But after introducing a for loop that iterates from 0-15 the entire server went ape shit.

I tried setting the block type by pulling the block directly from the chuck, I also pulled the block from the world object with more success. But still, the error occurs.

Actions to reproduce (if known):

Attempt to use a block populator to draw a line of fences. My code as it currently stands is below:

PlotPopulator

package com.yooogle.homerealm;

import java.util.Random;

import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;

public class PlotPopulator extends BlockPopulator {

    @Override
    public void populate(World world, Random random, Chunk chunk) {

        try {
            for (int x=0; x<15; x++) {
                for (int z=0;z<15;z++) {
                    int realX = x + chunk.getX() * 16; //find the world location of chunk location x
                    int realZ = z + chunk.getZ() * 16;
                    world.getBlockAt(realX, 64, realZ).setType(Material.COBBLESTONE);
                }
            }
        } catch(Exception e) {
            e.printStackTrace();
        }

    }

}

HomeRealmGenerator

package com.yooogle.homerealm;

import java.util.Arrays;
import java.util.List;
import java.util.Random;

import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.util.noise.SimplexOctaveGenerator;

public class HomeRealmGenerator extends ChunkGenerator {

    private int currentHeight = 50; 

    @Override
    public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biome) {
        ChunkData chunk = createChunkData(world);

        SimplexOctaveGenerator generator = new SimplexOctaveGenerator(new Random(world.getSeed()), 8);
        generator.setScale(0.005D);

        for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {

                currentHeight = (int) ((generator.noise(chunkX*16+x, chunkZ*16+z, 0.5D, 0.5D)+1) * 15D + 50D );
                chunk.setBlock(x, currentHeight, z, Material.GRASS_BLOCK);
                chunk.setBlock(x, currentHeight-1, z, Material.DIRT);

                for(int y = currentHeight-2; y > 0; y--) {
                    chunk.setBlock(x, y, z, Material.STONE);
                }

                chunk.setBlock(x, 0, z, Material.BEDROCK);

            }
        }

        return chunk;

    }

    @Override
    public List<BlockPopulator> getDefaultPopulators(World world) {
        return Arrays.asList((BlockPopulator) new TreePopulator(), (BlockPopulator) new PlotPopulator());
    }

}

Paper build number:

[13:20:59 INFO]: This server is running Paper version git-Paper-621 (MC: 1.13.2) (Implementing API version 1.13.2-R0.1-SNAPSHOT)

Most helpful comment

You have to pass false to the update flag of setType in your populator, otherwise, you're going to be stuck in a recursive loop of chunk generation, loading, generation...

All 6 comments

You have to pass false to the update flag of setType in your populator, otherwise, you're going to be stuck in a recursive loop of chunk generation, loading, generation...

https://papermc.io/javadocs/paper/1.13/org/bukkit/block/Block.html#setType-org.bukkit.Material-boolean-

So would the applyPhysics boolean be the update flag you where referring to?

Yes, passing true to it will cause it to notify neighbouring blocks, loading the neighboring chunk if on a chunk border so that it can actually apply the update

Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

greenywd picture greenywd  路  3Comments

Shevchik picture Shevchik  路  3Comments

successed picture successed  路  3Comments

Marlej-dev picture Marlej-dev  路  3Comments

tazuuuu picture tazuuuu  路  3Comments