Menu

#2035 Missing/corrupt data in-game while using Test Game

OHRRPGCE
open
nobody
Live previewing
Windows (please specify version)
Bug Report
20171201 Etheldreme
2020-03-15
2018-08-28
TeeEmCee
No

Wobbler reported once:

...while testing my game, I went into a shop to sell some items and every option was blank. It still showed the correct sell price and I could sell stuff, but I couldn't see any of the item names. I closed the game, opened it again, and everything was back to normal

SwordPlay also said he'd seen something like it, but couldn't remember anything at all.

While Custom is writing a lump it locks it to ensure that Game doesn't simultaneously try to read it. However, our load/save code often opens and closes a file multiple times, or writes multiple files, and there's no synchronisation around such operations to prevent Game from seeing inconsistent state. So I think there are a lots of weird things you might see if you get very unlucky.

In the case of item names note we don't cache those, and instead open .ITM to read the name of each item in a shop. But the names of the things in a shop are taken from STF, not ITM. The real item names are used on the right-hand-side info pane. The STF records for a shop are read/written all at once, so I don't know how what Wobbler saw could happen.

This bug report isn't specifically about shops though.

Discussion

  • TeeEmCee

    TeeEmCee - 2018-08-28

    Just found a comment by Foxley: "Uh oh, the game just crashed when I went to the Sell menu in a shop"
    No additional information, don't know whether he was using Test Game.

     
  • TeeEmCee

    TeeEmCee - 2018-08-30

    I've discovered that the file locking done on Windows doesn't actually prevent Game from seeing a file in the middle of being written. If a file is opened ACCESS WRITE (aka ACCESS_WRITE), whether using the locking I implemented in OPENFILE, or FB's builtin locking if OPEN is used with LOCK, the file is first opened for write, which truncates it to length zero, and then is locked. And it turns out it's actually really common to hit the file at that exact moment if both Game and Custom are opening it often.

    I should be able to make OPENFILE work around this problem.

    However ACCESS WRITE is only used in 16 places, and shop and item data aren't among them.

     
  • TeeEmCee

    TeeEmCee - 2020-03-15

    This bug has been migrated to our new issue tracker on Github: https://github.com/ohrrpgce/ohrrpgce/issues/1094

     

Log in to post a comment.