-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Py3 engine segfaults when using a savefile from a py2 engine #149
Comments
@evertvorster - is this issue still relevant, or it was related to the old savefile? |
@nabaco, I am now doing a test run. More on this test in a few minutes |
@nabaco, still an issue. Attached is the console log of the crash. I'll keep the save files around if you have any other tests for me to try on them |
Hi, |
@P-D-E Hmm, very interesting. Thanks for the tip. |
For reference, CP1252 is a DOS/Windows Code Page reference (Code Page 1252) which is how DOS/Windows did region/language support years back. It kind of makes sense that the age of the saved game file might require an encoding update; though I wonder if we an fix that automatically... |
The funny thing is my saved game comes from Linux, I expected it to be UTF-8 already, but the command |
I'm going to look into this a little more, I will say that in all my Python work I always hated getting the following error:
It can occur with both Py2 and Py3 when something doesn't convert to-from Unicode correctly. Any how, I'm going to try to reproduce this using master/0.8.x through the following:
If that works, then we'll need to do some more deep dive to find what kinds of data is getting into the saved game file that is causing the error. |
By the way, here's one offending line from one of my old saves: |
@P-D-E cool - yeah, that's probably what's doing it. I might have to create some kind of tool to try to detect stuff; fortunately it should be an easy python script - read, parse, drop.... |
Assets-Production/universe/fgnames is the source of those names, but they've been purged of those characters from 0.6.x on (e.g. Hssleholm). |
@P-D-E thanks; it'll certainly be a migration effort for supporting older installs, and folks that are still using the 0.5.x Windows/Mac stuff. |
@BenjamenMeyer I tested the conversion with a short Python script, should it become a command-line tool available to people with old savefiles? |
@P-D-E that would be awesome! Probably something we should provide by default with the engine. |
@BenjamenMeyer Here's a prototype: |
@P-D-E looks good; if we cna get a verification then it'd be great to be able to bundle that into the main VS Engine as a utility tool |
Real life is getting in the way of coding at the moment, and that is probably a good thing! My thought on this... should the engine not detect that it's a Py2 savegame and convert it automatically? Once it's saved, it's a Py3 savegame. :) |
@evertvorster if possible, certainly. First is reliably reproducing and identifying the cause so we can fix and know we're know breaking things. Oh, and yeah - it's a good thing that Real Life is getting in the way since that pays the bill ;) so when you can it'd be appreciated! |
Reproduction:
I'll have to dig into this later. I did check with the current release (0.7.0) and there is no issue there. So this is really about bringing old games forward from our vast group of users from years past. While many have likely lost the game files, there is still a good chance many have not, especially since we're still promoting 0.5.x on Windows and Mac for the time being. Also checked that running the engine with Py2 and loading the same file doesn't crash the engine. So this is very much explicitly a Py2 vs Py3 thing. |
Digging into this a little by following the stack trace...which unfortunately isn't terribly helpful since...
Unfortunately I don't think there's a good way to solve this based on my little review thus far of Of course, I'm just getting into this so I'm all 👂s for better solutions |
@BenjamenMeyer, it comes down to what the goal is. If it's to have the simplest user experience, then there needs to be some way for the game engine to detect which Python was used to save a game, and then run a conversion utility internally. If, on the other hand, the goal is to have a simple easily maintainable code base, then adding this complexity is a bad thing, as Python 2 is gone. Having an external conversion utility would then be the way to go, as a nod to all the long time users of the software. However, it's your time, and you can spend it working on bit you really like. :) |
@evertvorster agreed. The main goal is to help users with old save game files not lose what they had as they move into the newer installs as IMHO that's a bad user experience. However, I'm not sure it's worth the effort to have it in-game:
So I'm thinking having the external tools will help mitigate things for the time being; though it'd be great to be able to provide some utilities with the game for users to detect such things, and possibly fix them if possible. I'm guessing this would mean:
Ultimately we want more easily maintainable code. If in the long run/process we can move this into the engine then great; if not then it's probably not a huge deal. |
I'm with @BenjamenMeyer on this; the conversion is only needed once at most, and to me it's more like a post-install step. Besides, I've discovered a nasty legacy from 0.5, the Now, it's only 3 names out of 640, so the chances they slipped into a savefile are low (none were in my savefiles), but a bad user experience is to avoid at all costs. So I had to add a fallback byte-mode handling to the tool, in case the cp1252 text read fails; this is the exact kind of thing I'd rather not burden an engine with, if possible. That said, I think it'd be nicer if the assets shipped the squadron names with all the diacritics back; the conversion can be done manually with an editor like Leafpad, or even with the vssc tool itself, bar the |
A small change that doesn't require exceptions could be to change the signature for I wonder if it's possible (directly or indirectly) to pass said boolean on to the asset-level python code perhaps? If so, you could guard it with an if-statement and execute the fallback in an else-clause when attempting to load a game from the python assets? These are the places in the code where
|
The saved game is very tightly tied to the universe data that is generated with the first run of the game. |
Okay I'm a bit closer now... @ermo I did add the return value...unfortunately that leaves it in an even worse state for the moment as the game just hangs on the load screen. I did trace it to being loaded from the call in cockpit_generic.cpp; but now I need to figure out how to revert to the previous screen. @Loki1950 @P-D-E any pointers on doing the screen reversion would be appreciated; it's not very clear to me at the moment. But I'll keep poking around. I'll probably put this up as a draft PR so you all can start seeing the changes, etc too. UPDATE: See #453 for the Draft PR. |
Loading an invalid saved game file should error out. This goes part way, but hangs on the loading screens.
It may be worth trying to summarise the current thinking on how to handle the migration to Py3 and its "strings are UTF-8 by default" requirements: Short-term goal:
The short term goal appears to be achievable if we adopt @P-D-E 's C++ PR here (where the Python side imports the exported C++ check via the VS module). @royfalk suggested an alternative approach, where Boost C++ conversion functions are used. This alternative implementation could still be exposed using the same function signature as @P-D-E 's C++ PR, which means that the underlying C++ implementation (be it the custom C++ code or a suitable amalgamam of Boost functions) need not be set in stone. Longer term goal:
For us to move forward, a consensus needs to be built that we agree that the short-term goal can be met with @P-D-E 's PRs (possibly looking into using Boost functions as an alternative as suggested by @royfalk ) and that, while the proposed solution is not necessarily a long-term one, it will mitigate the immediate blocker for Py3 migration and thus, on reflection, be worth the possible future churn in terms of refactoring. If you agree with my description and proposed short-term goal + solution and are ready to punt on the longer-term goals, respond with a 🚀 emoji. If you agree in principle, but think this needs more discussion, give a 👍 and make a comment describing your preferred 0.8.x solution. If you disagree with most or all of the above, give a 👎 and make a comment describing your preferred 0.8.x solution. |
I don't know enough about this side of the game to voice my opinion. I'd note that adding an exception hierarchy or switching all strings to unicode to the code base will be hard to do. |
We need to create a list of all the ways that a game can be loaded and tested. Thus far I'm aware of:
In testing #471 I found it failed use case 2 but use case 3 was resolved. I haven't tried use case 1 yet. We need to verify all of these to ensure this is properly solved so users don't end up in a bad state. |
Use case 2 depends on the Python call to the C++ check, and that one is in Assets; the test will fail with assets older than pull 62. |
@P-D-E thanks; verified. I'm not sure how to kick off the 3rd use case. Doing:
Doesn't seem to work, it dumps out with a crash about not finding the mission, and nothing from the command-line options doesn't seem to align...looking closely at |
By the time it gets there, the mission object has already been populated. Try inspecting what happens in |
@P-D-E i'm guessing VS doesn't directly support loading a saved game from the command-line, but as a side-effect of loading specific missions for testing purposes; more investigation certainly needed. We can probably get by for 0.8.x as that is probably more of a dev tool. |
@BenjamenMeyer That's surely the case of the unit converter, which lets users see their models in action via |
@P-D-E thanks. Closing this out |
Hey there. I am playing with the latest vegastrike engine from master.
It has been compiled with PYTHON3=ON, and using the system boost libs.
So far, it's been going well. Due to the "jumping around issue" I personally don't think it's related to the SPEC, I have been trying a python2 version, as well as older branches of the engine. During this time I also advanced a little in the game, doing Janus' missions.
Now I have reverted back to python3 and the latest master, and I get a segfault when the ship launches. When the engine is Python2, and the same savefile, there is no segfault.
I have attached the savefile to this report.
Evert_empty.tar.gz
Here is the interesting bit of the error message:
-----snip---------
Adding news
finding nonloaded quest
quest_tutorial
finding quest
quest_tutorial
nonpfact
removing quest
Processing News
Compiling python module bases/launch_music.py
Traceback (most recent call last):
File "/usr/share/vegastrike/modules/missions/privateer.py", line 34, in Execute
i.Execute()
File "/usr/share/vegastrike/modules/random_encounters.py", line 291, in Execute
dynamic_battle.UpdateCombatTurn()
File "/usr/share/vegastrike/modules/dynamic_battle.py", line 42, in UpdateCombatTurn
lookorsiege=LookForTrouble (fac)
File "/usr/share/vegastrike/modules/dynamic_battle.py", line 367, in LookForTrouble
randomMovement (i,faction)
File "/usr/share/vegastrike/modules/dynamic_battle.py", line 258, in randomMovement
fg_util.TransferFG( fg,fac,suggestednewsys);
File "/usr/share/vegastrike/modules/fg_util.py", line 425, in TransferFG
_RemoveFGFromSystem(fgname,faction,starsystem)
File "/usr/share/vegastrike/modules/fg_util.py", line 251, in _RemoveFGFromSystem
if Director.getSaveString(ccp,key,index) == fgname:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe3 in position 2: invalid continuation byte
terminate called after throwing an instance of 'boost::python::error_already_set'
/usr/bin/vs: line 7: 7015 Aborted (core dumped) vegastrike -d/usr/share/vegastrike
[evert@Vorster vegastrike-engine-git]$
The text was updated successfully, but these errors were encountered: