[Scummvm-devel] Use of exceptions / setjmp in Lua

Max Horn max at quendi.de
Tue Oct 19 13:18:07 CEST 2010


Hi there,

I just saw bug report #3090234 "SWORD25: Code analysis warnings", and that pointed out the following issue (amongst others):

d:\sources\scummvm\scummvm\engines\sword25\util\lua\ldo.cpp(118): warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable
This is not an analysis warning. It might need to be disabled in the property file when generating the project files with create_msvc if deemed invalid

Looking at luaconf.h, it turns out that the Lua code indeed makes use of setjmp. That's rather bad news, as setjmp is not that portable. Instead of setjmp, Lua can apparently also use C++ exceptions -- something we have tried to avoid so far (and disabled in our build system). Still, I figure it might cause less harm to use those than to use setjmp. But either way, we'll have to deal with this. 

On the short run, we could get along by adding a setjmp configure check, and disabling the sword25 engine if setjmp is not present and working.

On the long run, we could remove the Lua code again and rely on it being provided as an external dependency, which would be free to use setjmp or throw/catch.

However, we then still would have the problem of pluto being tightly linked to the exact Lua version... However, note that from the pluto homepage <http://lua-users.org/wiki/PlutoLibrary>, though, it sounds as if any Lua 5.1.x version would be acceptable. Is that correct?

Anyway, as I see it, pluto may have some other issues. For example, from some things I read while googling around, I got the impression that pluto does not store data in a platform independent way. Hence, sword25 savestates would not be portable across platforms, assuming they make use of pluto. If anybody knows more about this, then please chime in!

The Pluto project also seems to be dormant (see e.g. this unhandled bug report about issues on 64bit systems: <http://luaforge.net/tracker/index.php?func=detail&aid=47527&group_id=31&atid=216>). 

There is a fork on github <http://github.com/hoelzro/pluto> which might be interesting to investigate, it even provide a roadmap. Well, and we could also simply try to contact the original Pluto author as well as the fork's author...


Cheers,
Max





More information about the Scummvm-devel mailing list