1. Welcome to LilyPad. Download the project, explore the forums, and create your own LilyPad network.


    If you use the software and enjoy it or have a question, or would like to contribute to the future of the software directly or through resources, please sign up and join our little community.

Resolved Packet 63 crash (world particles)

Discussion in 'Bug Reports' started by chylex, May 10, 2013.

Thread Status:
Not open for further replies.
  1. chylex

    chylex New Member

    Hello, I made a bukkit plugin which spawns particles using Packet 63 (0x3F). When I don't have the server connected to lilyPad, everything works fine, but if I use lilyPad, it shows errors and all clients who receive the packet time out.
    Code (text):

    [LilyPad] build 16 of AllInOne
    io.netty.handler.codec.DecoderException: java.lang.NullPointerException
            at io.netty.handler.codec.ReplayingDecoder.callDecode(ReplayingDecoder.java:459)
            at io.netty.handler.codec.ByteToMessageDecoder.inboundBufferUpdated(ByteToMessageDecoder.java:69)
            at io.netty.channel.ChannelInboundByteHandlerAdapter.inboundBufferUpdated(ChannelInboundByteHandlerAdapter.java:51)
            at io.netty.channel.DefaultChannelHandlerContext.invokeInboundBufferUpdated(DefaultChannelHandlerContext.java:896)
            at io.netty.channel.DefaultChannelHandlerContext.fireInboundBufferUpdated0(DefaultChannelHandlerContext.java:864)
            at io.netty.channel.DefaultChannelHandlerContext.fireInboundBufferUpdated(DefaultChannelHandlerContext.java:843)
            at io.netty.handler.timeout.ReadTimeoutHandler.inboundBufferUpdated(ReadTimeoutHandler.java:149)
            at io.netty.channel.DefaultChannelHandlerContext.invokeInboundBufferUpdated(DefaultChannelHandlerContext.java:917)
            at io.netty.channel.DefaultChannelHandlerContext.fireInboundBufferUpdated0(DefaultChannelHandlerContext.java:864)
            at io.netty.channel.DefaultChannelHandlerContext.fireInboundBufferUpdated(DefaultChannelHandlerContext.java:843)
            at io.netty.channel.DefaultChannelPipeline.fireInboundBufferUpdated(DefaultChannelPipeline.java:1017)
            at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:115)
            at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:460)
            at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:424)
            at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:360)
            at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:103)
            at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.NullPointerException
            at lilypad.server.proxy.packet.GenericPacketCodec.decode(GenericPacketCodec.java:24)
            at lilypad.server.proxy.packet.GenericPacketCodec.decode(GenericPacketCodec.java:14)
            at lilypad.server.proxy.packet.GenericPacketCodec.decode(GenericPacketCodec.java:7)
            at lilypad.packet.common.PacketDecoder.decode(PacketDecoder.java:16)
            at lilypad.packet.common.PacketDecoder.decode(PacketDecoder.java:7)
            at io.netty.handler.codec.ReplayingDecoder.callDecode(ReplayingDecoder.java:404)
            ... 16 more
    io.netty.handler.codec.DecoderException: java.lang.NullPointerException
            at io.netty.handler.codec.ReplayingDecoder.callDecode(ReplayingDecoder.java:459)
            at io.netty.handler.codec.ReplayingDecoder.channelInactive(ReplayingDecoder.java:371)
            at io.netty.channel.DefaultChannelHandlerContext.invokeChannelInactive(DefaultChannelHandlerContext.java:752)
            at io.netty.channel.DefaultChannelHandlerContext.fireChannelInactive(DefaultChannelHandlerContext.java:738)
            at io.netty.channel.ChannelStateHandlerAdapter.channelInactive(ChannelStateHandlerAdapter.java:69)
            at io.netty.handler.timeout.ReadTimeoutHandler.channelInactive(ReadTimeoutHandler.java:143)
            at io.netty.channel.DefaultChannelHandlerContext.invokeChannelInactive(DefaultChannelHandlerContext.java:752)
            at io.netty.channel.DefaultChannelHandlerContext.access$1600(DefaultChannelHandlerContext.java:36)
            at io.netty.channel.DefaultChannelHandlerContext$6.run(DefaultChannelHandlerContext.java:743)
            at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:276)
            at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:365)
            at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:103)
            at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.NullPointerException
            at lilypad.server.proxy.packet.GenericPacketCodec.decode(GenericPacketCodec.java:24)
            at lilypad.server.proxy.packet.GenericPacketCodec.decode(GenericPacketCodec.java:14)
            at lilypad.server.proxy.packet.GenericPacketCodec.decode(GenericPacketCodec.java:7)
            at lilypad.packet.common.PacketDecoder.decode(PacketDecoder.java:16)
            at lilypad.packet.common.PacketDecoder.decode(PacketDecoder.java:7)
            at io.netty.handler.codec.ReplayingDecoder.callDecode(ReplayingDecoder.java:404)
            ... 12 more
     
    As you can see in the log, I use AllInOne server. I tried sending the packet using playerConnection.sendPacket(packet) and also ProtocolLib, both work perfectly without lilyPad on which made me believe it's an error in lilyPad. This is the code I use, in case you need it:
    Code (text):
    PacketContainer packet=protocol.createPacket(63);
                packet.getSpecificModifier(String.class).write(0,(String)effect.getEffect());
                packet.getSpecificModifier(float.class)
                    .write(0,(float)player.getLocation().getX())
                    .write(1,(float)player.getLocation().getY()+0.5F)
                    .write(2,(float)player.getLocation().getZ())
                    .write(3,effect.getOffset(rand))
                    .write(4,0.5F)
                    .write(5,effect.getOffset(rand))
                    .write(6,effect==Effect.SMOKE?0.04F:0.25F);
                packet.getSpecificModifier(int.class).write(0,effect.getAmount());
                try{
                    for(Entity e:player.getNearbyEntities(16D,16D,16D)){
                        if (e.getType()==EntityType.PLAYER)protocol.sendServerPacket((Player)e,packet);
                    }
                    protocol.sendServerPacket(player,packet);
                }catch(InvocationTargetException e){}
    Thanks for help, hope you can quickly fix it :)
  2. Coelho

    Coelho Software Engineer Staff Member Administrator Maintainer

    Code (text):

    opPairs[0x3F] = new OpPair[] { shortSizedDoubled, jump(8 + 8 + 8 + 8 + 8 + 8 + 8 + 4)};
     
    Straight from LilyPad, and it is reading the packet correctly. Please ensure you are sending the packet properly (by viewing the byte array produced), as LilyPad is very strict on the integrity of packets to ensure the absence of Layer 7 attacks. Please also make sure that this is the packet causing it, and you are not sending any others that may be offenders.
  3. chylex

    chylex New Member

    Well, the packet is handled by ProtocolLib so it should be okay - 1 string, 7 floats and 1 integer, no other data in the packet. I'm 100% sure that it's the 0x3F packet, I don't send any other packets and the crash happens for 'player' and players 16 blocks away from him, so I have no doubt it's causing the issue.

    I don't create the byte array nor I have access to it, that should be handled by the server. ProtocolLib just uses the playerConnection.sendPacket(packet) field in CraftPlayer, is there a special way of sending packets, that's specific to LilyPad?
  4. Coelho

    Coelho Software Engineer Staff Member Administrator Maintainer

    What packet class is being sent however? Is it using the 0x3F packet class, or is it using it's own custom version due to you using createPacket that just has a custom byte array? That's what I'm a bit wary of at this point.

    Can you try to trace down how it actually creates and sends the packet so we can see if it is doing it properly?
  5. chylex

    chylex New Member

    createPacket just creates a PacketContainer, which is an easy way of setting packet data and then send it without any reflection and craftbukkit references in the plugin file, it's the ProtocolLib API. It creates a regular vanilla packet and fills in the data I specified, then sends it. I checked packet.toString() and it was Packet63WorldParticles which is correct, so it looks like it does the job good.

    I also tried it with my own code, where I created an instance of Packet63WorldParticles and used reflection to set the fields. Again, just like the ProtocolLib solution, it works until I use LilyPad.

    I really have no idea what could be the problem, both solutions lead to the same result (sendPacket()). I do have Minecraft decompiled and there's no field in the packet that I could've missed. Does LilyPad change the sendPacket() method, or does it have a special way of sending packets I have to use instead of the craftbukkit's one?
  6. Coelho

    Coelho Software Engineer Staff Member Administrator Maintainer

    Ah apologies. Jenkins should be building a fix for this in a minute.
  7. chylex

    chylex New Member

    Thank you :)
Thread Status:
Not open for further replies.

Share This Page