debugging help: Triggering profiling crash in vanilla

keybounce

New Member
Jul 29, 2019
1,925
0
0
AAAAAAA...

Help me internet, you're my only hope.

I am getting a crash in vanilla code when I try to use the profiler.
I have no idea why.

First, my support routines (the intention here was to give me a place to put breakpoints):
Code:
    public static void startProfileSection(String sectionName)
    {
        Minecraft.getMinecraft().mcProfiler.startSection(sectionName);
    }

    public static void endProfileSection()
    {
        Minecraft.getMinecraft().mcProfiler.endSection();
    }

    public static void endStartSection(String sectionName)
    {
        Minecraft.getMinecraft().mcProfiler.endStartSection(sectionName);
    }

I have this routine:

Code:
    @SubscribeEvent
    public void chunkUnload(final ChunkEvent.Unload event)
    {
        RealisticFluids.startProfileSection("chunkUnload");
        System.out.println("Unloading chunk " + event.getChunk().xPosition + ", " + event.getChunk().zPosition);
        if (FluidData.worldCache.get(event.world) != null)
            FluidData.worldCache.get(event.world).chunks.remove(event.getChunk());
        RealisticFluids.endProfileSection();
    }

This is the ONLY place in my code where I'm calling the profiler (every thing else is commented out).

If I move back and forth over a chunk line, I crash in this part of vanilla:

Code:
            this.theProfiler.startSection("tick");

            if (!entity.isDead)
            {
                try
                {
                    this.updateEntity(entity);
                }
                catch (Throwable throwable1)
                {
                    crashreport = CrashReport.makeCrashReport(throwable1, "Ticking entity");
                    crashreportcategory = crashreport.makeCategory("Entity being ticked");
                    entity.addEntityCrashInfo(crashreportcategory);

                    if (ForgeModContainer.removeErroringEntities)
                    {
                        FMLLog.getLogger().log(org.apache.logging.log4j.Level.ERROR, crashreport.getCompleteReport());
                        removeEntity(entity);
                    }
                    else
                    {
                        throw new ReportedException(crashreport);
                    }
                }
            }

            this.theProfiler.endSection();

That endSection call gives a null pointer exception because there's too many pops off the profiling stack.

Seriously, what the heck? What am I doing wrong?

https://[email protected]/keybounce/minecraft-finite-fluids.git
1a936d4..fd3f95a Profiling -> Profiling