Skip to content
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

Starting then exiting desktop with 14 ProDOS devices corrupts device table #549

Closed
apple2geek opened this issue Aug 29, 2021 · 2 comments
Closed
Labels
bug DeskTop DeskTop bugs or feature requests
Milestone

Comments

@apple2geek
Copy link
Contributor

Describe the bug
If your system has sufficient storage devices to have a full device table with 14 active ProDOS devices (two for each slot), and you start, then exit A2Desktop, one of the device entries in the device table will be corrupted/damaged preventing access to that device until a reboot.

To Reproduce
Steps to reproduce the behavior:

  1. Boot a system with enough storage devices to have the maximum 14 active ProDOS devices
  2. Start DeskTop
  3. Exit DeskTop
  4. Use any other ProDOS app or program selector that queries or enumerates the device list
  5. Observe that one of the device entries is corrupted (in my case, I got a phantom "Slot 0, Drive 1" device with a volume name of "/" instead of the previously-present "Slot 7, Drive 2" device which was now gone).

Expected behavior
All 14 original devices should be properly restored upon exit from Desktop.

Screenshots
Sorry, I didn't get any screenshots of the error while it was in effect.

System Details (please complete the following information):

  • System [Platinum Apple //e, with MicroDrive/Turbo having 11 partitions, and Disk II controller]
  • Emulator? [No, physical hardware]
  • ProDOS version [2.4.2]
  • DeskTop version [1.2-alpha34, git pull a8b5226]
  • Other [Mouse, GW8M, Mockingboard, Uthernet II, Super Serial, Grappler Pro, ROMXe, ]

Additional context
The combination of /RAM, two Disk II drive entries, and the 11 MD/T partitions fills the ProDOS device table with 14 entries at startup.

@apple2geek apple2geek added bug DeskTop DeskTop bugs or feature requests labels Aug 29, 2021
@apple2geek
Copy link
Contributor Author

I traced this to the code in desktop/init.s, lines 202-211, which makes a backup of the existing device list. The device list entries, including the previous byte which contains the device count, are copied to a spare area of RAM, defined as "devlst_backup". In a system with the maximum 14 devices active, this is a total of 15 bytes.

The space to hold the backup, "devlst_backup" is defined in desktop/res.s, lines 940-941, based on the value of kMaxVolumes:
devlst_backup:
.res kMaxVolumes+1, 0 ; TODO: Why +1?

kMaxVolumes is defined elsewhere as 13 (the maximum # of Volumes that DeskTop will support), so this allocates 14 bytes, but the space needed for a full 14-device backup is 15 bytes as mentioned. That last/15th byte crosses over into the next structure in memory, "device_to_icon_map", where it gets overwritten as DeskTop runs.

When DeskTop exits, the device list is restored from devlst_backup, but if there are 14 devices, the last entry in the list is no longer correct.

@apple2geek
Copy link
Contributor Author

Proposed fix: Change desktop/res.s lines 940-941 to:

devlst_backup:
.res 15, 0 ; Because there's ALWAYS 14 devices possible + DEVCNT

Or similar. The size of the devlist backup area should be based on the size of the ProDOS structure being backed up, not the # of DeskTop Volumes supported.

@inexorabletash inexorabletash added this to the 1.2 milestone Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug DeskTop DeskTop bugs or feature requests
Projects
None yet
Development

No branches or pull requests

2 participants