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

BufferUnderflowException / Physics Error #221

Open
subdavis opened this issue Mar 30, 2016 · 1 comment
Open

BufferUnderflowException / Physics Error #221

subdavis opened this issue Mar 30, 2016 · 1 comment

Comments

@subdavis
Copy link

Hello Folks.

I've been having a lot of fun trying to understand how this project works, and I've been able to hack apart enough of the code to get a "followbot" sporadically working on the cuberite server clone.

Unfortunately, I'm getting the following error with both the example code and my 'follow bot' plugin.
[DEBUG]: Physics failed to generate an MTV, bailing out
that message spams the console until I ^c out.

The error above is with a default vanilla server, version 1.8.8

Using the same code with a cuberite server (the C++ clone from http://cuberite.org/ ), I get

[DEBUG]: EVENTCORE: Exception while emitting PLAY<Chunk Data [02:03:38] <<< (0x03, 0x21): Chunk Data                    {'chunk_z': 8, 'data': b'', 'continuous': True, 'primary_bitmap': 0, 'chunk_x': 3}
[DEBUG]: EVENTCORE: Exception while emitting SOCKET_RECV None
[DEBUG]: EVENTCORE: Exception while emitting event_tick None
Traceback (most recent call last):
  File "bot.py", line 55, in <module>
    client.start(SERVER, 25565)
  File "/home/brandon/GitCode/SpockBot/lib/python3.4/site-packages/spockbot-0.1.3-py3.4.egg/spockbot/plugins/helpers/start.py", line 34, in start
  File "/home/brandon/GitCode/SpockBot/lib/python3.4/site-packages/spockbot-0.1.3-py3.4.egg/spockbot/plugins/core/event.py", line 29, in event_loop
  File "/home/brandon/GitCode/SpockBot/lib/python3.4/site-packages/spockbot-0.1.3-py3.4.egg/spockbot/plugins/core/event.py", line 36, in run_continuous
  File "/home/brandon/GitCode/SpockBot/lib/python3.4/site-packages/spockbot-0.1.3-py3.4.egg/spockbot/plugins/core/event.py", line 62, in emit
  File "/home/brandon/GitCode/SpockBot/lib/python3.4/site-packages/spockbot-0.1.3-py3.4.egg/spockbot/plugins/core/net.py", line 193, in tick
  File "/home/brandon/GitCode/SpockBot/lib/python3.4/site-packages/spockbot-0.1.3-py3.4.egg/spockbot/plugins/core/event.py", line 62, in emit
  File "/home/brandon/GitCode/SpockBot/lib/python3.4/site-packages/spockbot-0.1.3-py3.4.egg/spockbot/plugins/core/net.py", line 209, in handle_recv
  File "/home/brandon/GitCode/SpockBot/lib/python3.4/site-packages/spockbot-0.1.3-py3.4.egg/spockbot/plugins/core/net.py", line 145, in read_packet
  File "/home/brandon/GitCode/SpockBot/lib/python3.4/site-packages/spockbot-0.1.3-py3.4.egg/spockbot/plugins/core/event.py", line 62, in emit
  File "/home/brandon/GitCode/SpockBot/lib/python3.4/site-packages/spockbot-0.1.3-py3.4.egg/spockbot/plugins/helpers/world.py", line 64, in handle_chunk_data
  File "/home/brandon/GitCode/SpockBot/lib/python3.4/site-packages/spockbot-0.1.3-py3.4.egg/spockbot/plugins/tools/smpmap.py", line 217, in unpack_column
  File "/home/brandon/GitCode/SpockBot/lib/python3.4/site-packages/spockbot-0.1.3-py3.4.egg/spockbot/plugins/tools/smpmap.py", line 188, in unpack
  File "/home/brandon/GitCode/SpockBot/lib/python3.4/site-packages/spockbot-0.1.3-py3.4.egg/spockbot/plugins/tools/smpmap.py", line 106, in unpack
  File "/home/brandon/GitCode/SpockBot/lib/python3.4/site-packages/spockbot-0.1.3-py3.4.egg/spockbot/mcp/bbuff.py", line 14, in read
spockbot.mcp.bbuff.BufferUnderflowException

That bot follows me for 1-10 seconds, and then crashes. The default example code never crashes on cuberite, but the single startup call to move_to does not cause the bot to move. I suspect this call is simply too soon after the bot was initialized, because subsequent calls work (until the error is thrown)

The only code that changed in my follow bot is the entity_move handler:

def entity_move_handler(self, name, data):
        #Get the Entity object from data.  
        #Has 'entity' and 'old_pos' or something like that.
        entity = data['entity']
        #Check if the entity was a player
        if (entity.eid in self.entities.players):
            logger.info("{0} moved to {1} {2} {3}".format(entity.metadata, entity.x, entity.y, entity.z))
            target = Vector3(entity.x, entity.y, entity.z)
            self.movement.move_to(*target)

Obviously this error is caused by my call to move_to(*target) - I can comment it out and nothing crashes.

Thanks!

@subdavis subdavis changed the title BufferUnderflowException or BufferUnderflowException / Physics Error Mar 30, 2016
@nickelpro
Copy link
Member

No idea why Physics would be wigging out, but our example code is bad and has a history of making bad things. [DEBUG]: Physics failed to generate an MTV, bailing out means the bot thinks it's inside of something and can't figure out how to not collide with it.

The crash is caused by smpmap trying to read biome data out of an empty chunk packet that Cuberite is using to unload the chunk. I'm not sure what the correct behavior here is, I think the vanilla behavior is still to send the biome data even though bitmask is empty, so Spock should be OK to expect it.

Still, what SpockBot should probably do is just unload the chunk when he gets an empty bitmask, avoids the problem entirely.

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