megamarc/PyTilengine

Obscure error caused by seemingly arbitrary code

Closed this issue · 3 comments

I've been using PyTilengine and Tilengine 2.4.0 on Ubuntu 18.04 quite a lot recently for my current project, and I have noticed some very unusual behaviour. Occasionally, after adding some code to my project, I get the following obscure error:

  File "game.py", line 249, in <module>
    engine = Engine.create(HORIZONTAL_RES, VERTICAL_RES, BACKGROUND_LAYERS, NUMBER_OF_SPRITES, ANIMATION_SLOTS)
  File "/home/daniel/development/game/my_game/tilengine.py", line 374, in create
    _raise_exception(ok)
  File "/home/daniel/development/game/my_game/tilengine.py", line 304, in _raise_exception
    raise TilengineException(error_string.decode())
tilengine.TilengineException: 'No error'

I have no way of determining what is causing the arbitrary error and so I often have to undo recent changes until the code runs without the error. Here is one example of how bizarre the behaviour is, I had the following line of code which was causing the error:

if weapon.weapon_type == 'rail_gun':
    ...

but if I add this modification, the error would not be triggered:

if weapon.weapon_type == 'rail_gunn':
    ...

What's odd is that this line would be way further down the code than when I initialise the engine, so it is most certainly not a run-time error, and it's clearly not a syntax error. The only thing I can think of is that it has something to do with the number of characters in the game.py file.

As a workaround, I figured out that I can get the code to run again by repeatedly adding a pass statement in my main game loop. I would add a statement, then try and run, then add another and try again, until it would run.

Any idea as to what the real issue is? I have not seen anything like this before and it is very difficult to reproduce.

Hi Daniel,

This kind of puzzling errors cannot be fixed giving general advice, the exact situation that produces the error must be reproduced and examined in detail. As I don't have access to your work, I can't give a clue.

However, I recently released version 2.4.2, that fixes a strange loading behavior of some specific pngs that caused the system to crash, only due to being using an outdated libpng version. This problem only affected Windows, because in Linux library distribution is totally different. Windows build is now fixed, just recompiling libpng with a newer Visual Studio version solved the problem.

I also updated a bit the Python binding, I added the logging support introduced in release 2.1.0. So my general advice so far would be:

  • Update to latest 2.4.2 tilengine release, if you're using Linux, you must build it yourself (it's easy)
  • Update python binding, enable full logging support and check its console dump: tln.set_log_level(tln.LogLevel.VERBOSE)

Let me know!

So I updated Tilengine and did carried on with development for a couple of hours. Fortunately, the error didn't resurface, so it looks like the issue has been resolved. Hopefully it won't come up again. Thanks for all your help!

So the error seems to be reappearing, although not as frequently since I updated Tilengine. I still don't know what exactly is causing the error, but adding arbitrary strings in print statements seem to work. Very strange. I will try and get a reproducible example with as little code as possible. However, this is quite difficult because the error seems very arbitrary.