I ran into a very similar issue with .cht files that I've been generating and I tracked down the issue to the "saved bit" (bit 3) in the first byte of the cht file. If this bit is cleared and the cheat is enabled (bit 2 cleared also) then when the rom loads it will get stuck in what appears to be an infinite loop.
Using the 1.53 Windows port, I found that the first byte of a cheat will be set this way when I generate a cht file with an initial value of 0x04 (disabled and no saved value), load the rom, open the cheat dialog, enable the cheat, then close the dialog by clicking ok. The saved value is not saved to the cht file and the byte is set to 0x00 (enabled and no saved value). Now I close snes9x, reopen it and load the rom. At this point the infinite loop is encountered and snes9x has to to be force closed (I didn't spend anytime trying to debug the actual location of the infinite loop (or whatever is causing the hang), but it must occur somewhere after S9xGetByteFree() is called in S9xApplyCheat() during rom loading).
The cht file should have been saved with the first byte of the cheat set to 0x08 in the use case above, but the Windows port (only tested 1.53) does not do this. If the cht file was saved properly, this infinite loop issue would have been avoided. It appears this issue I'm seeing with saving the cht file is caused in the "ID_CHEAT_ENTER" switch case starting at line 2166 in wsnes9x.cpp
DialogBox(g_hInst, MAKEINTRESOURCE(IDD_CHEATER), hWnd, DlgCheater);
S9xSaveCheatFile (S9xGetFilename (".cht", CHEAT_DIR));
In this code S9xSaveCheatFile() is called before
S9xApplyCheats(). I think these two lines should be swapped because S9xApplyCheats() is what sets the saved value and the saved bit properly, which we definitely want done before saving. I don't have a development environment setup to allow me to compile snes9x so I haven't been able to test this fix, but it should do the trick hopefully.
Looking at this code, it also becomes apparent that a simple workaround
is to re-open the cheat dialog and click ok again (so everytime you want to enable a cheat, open the dialog, enable the cheat, click ok, then reopen the dialog and click ok again). If you do this then the cht file will be saved properly and the next time you open snes9x with cheats enabled it will not get stuck.
It would be awesome if this could be fixed in the next release