Possible failed startup cause - empty jsons

Discussion in 'Bug Reports' started by Lazza, Aug 26, 2018.

  1. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    12,345
    Likes Received:
    6,572
    Hello,

    I had a mix of rF2 crash and PC crash last week, and I was left with empty Multiplayer.JSON and CustomPluginVariables.JSON files.

    By empty I mean the same size as before, but filled with 0x00.

    This was causing a JSON error at first, then when I removed the dodgy multiplayer file rF2 changed to a failed startup (no message) until I found and removed the plugin variables file.
     
    Juan CofiƱo and ADSTA like this.
  2. ADSTA

    ADSTA Registered

    Joined:
    Nov 19, 2011
    Messages:
    2,013
    Likes Received:
    1,369
    Thank you very much, very handy to know not to trust the reported size of a file but to check the actual content of files.
     
  3. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    984
    Likes Received:
    984
    That also happened to me with player.json, so it is better to have it backed up.
     
  4. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    12,345
    Likes Received:
    6,572
    @The Iron Wolf Ok, interesting. I know a couple of times I've had the player file renamed (.temp or similar) and not properly replaced, failed startup or something (possibly mucking around with plugins...), but I could be remembering rF1 on that as well. Hopefully they can track down scenarios where the file ends up useless like this and avoid it, or at least gracefully recover if files like these end up existing but empty.
     
    The Iron Wolf likes this.
  5. oppolo

    oppolo Registered

    Joined:
    Dec 7, 2015
    Messages:
    138
    Likes Received:
    57
    For me it is a known bug, sometimes it happens when rf2 does not close itself well. I have a backup of user folder avaible
     
  6. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    984
    Likes Received:
    984
    I sometimes wonder if it isn't rF2 issue, but instead how NTFS caching works. I have write caching policy values that are not recommended by MS and can lead to data loss (but I don't care on gaming PC). In fact, I hit that 0x0 zeroed file when one of the source files I worked on got emptied out when power company came to switch meter and turned off power :)
     
  7. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    12,345
    Likes Received:
    6,572
    @The Iron Wolf NTFS may be implicated, but for me not the write caching option you've selected as I haven't changed any of those settings on my system.

    Perhaps it's not an rF2 bug that causes the zeroed files, but it's nearly a bug to not write in a manner to help overcome this sort of thing. If it leads to the end user unable to start the game, verifying files through steam doesn't fix it, leaving the user with the options of reinstalling rF2, removing their player folder and starting again with settings, series stats (though not car setups if steam is saving those), or having enough knowledge to find and remove any zeroed files (which look fine from the outside, as they still have normal size) and still losing any custom settings they had in there,

    and,

    IF this could be avoided by the game renaming the existing file before rewriting it, allowing for later detection of a dead file and its automatic recovery (like the game does, or used to do, during startup with the player file), then I think that's something worth pursuing.

    Or at the very least, recognise a zeroed JSON file and treat it like it's not there so the game starts with the default values instead of exiting with or without an error. Still not ideal as the player could lose all sorts of settings and maybe not realise it, but at least their game will work.
     
    The Iron Wolf likes this.
  8. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    984
    Likes Received:
    984
    Yes, I agree, it is 1-2 hour bug fix really :)
     
  9. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    12,345
    Likes Received:
    6,572
    ... and here we are in 2023.

    The cliched "2 minute fix" aside, this .json corruption continues to happen.

    Can I propose a game code workaround?
    1. Check for empty (0kb, or NULLed contents) .json files on startup, and rebuild any dead ones.
    2. Make a backup of the 4 .json files after each successful startup, as a recovery point for step 1.
    Please?
     
    davehenrie and ThomasJohansen like this.

Share This Page