Menu

#2030 Plus/4 emulator hangs after a while

v3.x
pending-fixed
gpz
None
GTK3
xplus4
2024-07-16
2024-05-11
No

Problem occurs at
- GTK3VICE-3.8-win64
- GTK3VICE-3.8-win64-r44985
- GTK3VICE-3.8-win64-r45136

--1 ----------------------------------------
Start Plus4 emulator.
Wait a while (one hour or so).
Emulator is hanging, no input from keyboard is possible.
Reset machine CPU --> emulator works fine again (for a while ...)


--2 ----------------------------------------
Start Plus4 emulator.
Drag and drop any PRG file (simple BASIC program).
PRG is loading fine (except r45136!! *1)
PRG is executing fine
Wait a while (one hour or so).
Emulator is printing "BREAK" in endless loop (see screenshot)
Reset machine CPU --> emulator works fine again (for a while ...)


All these problems are repeatable every time.

*1)
r45136 crashes immediatly after dropping PRG file

1 Attachments

Discussion

  • gpz

    gpz - 2024-05-13

    Funky. This hints at a leftover 32bit variable used for CLOCK somewhere.

    Could you please test/confirm if the above also works reliably in warp mode?

     
  • Thomas Winkler

    Thomas Winkler - 2024-05-13

    Yes.
    Problem occurs also in WARP mode.
    Always.
    And really faster than in normal mode.

    It occurs in WARP mode in a few minutes ...

    Additionally I can say, the crash is a bigger problem many hours later.
    Normally the crashed emulation can be solved by a RESET.
    After many hours neither RESET can get emulation back to normal work.
    Must close the window and restart VICE.

     
  • gpz

    gpz - 2024-05-13

    i can confirm this (using warpmode). emu will slowly run slower and slower, the log will show "Sync is 1000ms behind" warnings.

    other observations:
    - even in warpmode the emu slowly grinds to a halt
    - the UI keeps being responsive (keyboard debug output is working)
    - switching sound off/on does NOT affect it at this point
    - switch the machine model from PAL to NTSC will bring it back into a working state (perhaps?)
    - when the emu is unresponsive, stepping in the monitor shows that it is stuck in the IRQ. Another IRQ will trigger right after RTI.

    It will need a bit of digging to locate the source of the problem, i guess :)

     

    Last edit: gpz 2024-05-14
  • gpz

    gpz - 2024-05-17

    played around a bit, there are some suspicious casts in src/plus4/tedtypes.h - but changing those leads to apparent random results (and don't fix the problem).

     
  • gpz

    gpz - 2024-05-21

    removing the cast in TED_LINE_START_CLK() breaks xplus4 in a similar way.....

     
  • gpz

    gpz - 2024-07-06

    It would be great if someone would bisect this and track down what revision introduced the problem

     
    • Uffe Jakobsen

      Uffe Jakobsen - 2024-07-08

      I'm using this command below for quick reproduction of the problem

      It always freezes on TI=144898 (and a few times on TI=144896) - with timer ticks around every 1/60 sec - that is a little over 40 minuttes (so it is "nice" that the problem can be reproduced in warp-mode)

      xplus4 -warp -keybuf "10 print ti: goto 10\nrun\n"
      

      It seems that commit rev 40432 has introduced the problem:

      https://sourceforge.net/p/vice-emu/code/40432/
      CLOCK has changed from uint32_t to uint64_t. Clkguard has been removed, which means no more large jumps backward in time to prevent CLOCK overflow, and all related complexity has been removed. Snapshot code has been updated to write and read the larger CLOCK values, which means all existing snapshots will no longer work.

       
      • gpz

        gpz - 2024-07-08

        yes, see my first reply :)

        However, the question is where this leftover variable IS - its probably something that (incorrectly) never was declared as CLOCK, and never handled the wraparound, so it is really hard to find.

         
        • Uffe Jakobsen

          Uffe Jakobsen - 2024-07-08

          I know - but now the bisection is done ;-)

           
          • gpz

            gpz - 2024-07-08

            Yes :) Also ~40minutes are pretty much exactly 2^32 cycles, which proves its really a clock overflow.

             
            • Uffe Jakobsen

              Uffe Jakobsen - 2024-07-08

              As far as I can see it is closer to 2^31 - indicating a signed int (int) - but that is all details - still it is damn hard to find... :-)

               
  • Uffe Jakobsen

    Uffe Jakobsen - 2024-07-13

    FYI: I just created a patch ticket containing a fix for this issue

    Patch #377 Fix for bug ticket #2030: Plus/4 emulator hangs after a while

    https://sourceforge.net/p/vice-emu/patches/377/

     
  • gpz

    gpz - 2024-07-15

    fixed via #377, try r45233

     
  • gpz

    gpz - 2024-07-15
    • status: open --> pending-fixed
    • assigned_to: gpz
     
  • Thomas Winkler

    Thomas Winkler - 2024-07-16

    Wonderful.
    Build r45234 runs fine since hours in warp mode.

    It seems it is fixed!

    Thank you very much!

     

Log in to post a comment.