Skip to content

fix: safe back-to-back environment loads and screen mode changes - #226

Merged
midwan merged 10 commits into
masterfrom
fix/environment-reload-screenmode
Oct 21, 2026
Merged

midwan merged 10 commits into
masterfrom
fix/environment-reload-screenmode

Conversation

@midwan

@midwan midwan commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Scripts can now load environments back to back without crashing Opus, and screen mode changes no longer leave OS 3.5 icon images laid out on the closed screen. The PR also has two smaller fixes from Peter Keunecke's reports: View As in the lister status pop-up, and a Screen Mode page that shows its mode list as soon as the Environment editor opens.

Issue

No tracker issue; the reports came from Peter Keunecke.

Related: BlitterStudio/amiberry#2491. On the test setup the reboot after the Opus crash also froze Amiberry, which made the crash look like a hang.

Changes

  • Back-to-back LoadEnvironment no longer crashes. The command replies before the load is done, so a script could start a second environment process while the first was still loading. Both freed the same button banks: Software Failure 0100000F (bad free address) in dopus_environment. HEAD (5.103) crashes the same way after 4–6 loads 3 s apart. Loads now run one at a time, in the order they were started, until the display is open again; waiting loads leave when Opus quits instead of holding up shutdown. The lister menu, user menu and scripts banks are swapped under their existing locks.
  • Closing the display waits for a backdrop picture that is still loading. GUI->pattern_lock was declared but never initialised or used, so a screen mode change, Hide or environment load could free the picture and close the screen while the pattern process was still decoding into it. The pattern process never holds the lock across display_update_pattern(), which waits for the main process and the listers. If the display was closed while it waited there, it starts the load again when the next display is already open, or gives up and display_open() starts a new pattern process, deciding under the same lock.
  • OS 3.5 icon images give back their pens before the screen closes. FreeRemapImage() left toolbar and button images from .info files laid out on the screen, so the next LayoutIcon() or the final FreeDiskObject() released pens through the closed screen's colour map. A lister's own toolbar (Set Toolbar / ARexx) keeps its cache only while the lister has a window, and builds it on the screen the window opens on. ARexx AppIcons free their remap before the icon is freed.
  • View As in the lister status pop-up. Clicking SRCE/DEST/OFF now offers View As (Name, Icon, Icon Action, Show All). A name-mode lister too large to move the pointer outside of had no in-window way to change its view.
  • Environment editor first page. The editor opens on the first page of a list sorted by translated name. In languages where Screen Mode or Sounds sorts first, that page came up empty until another page was picked; both lists now show at once.

The revision bump is left to the release, as in recent PRs.

Affected platforms

  • AmigaOS 3 (os3)
  • AmigaOS 3 / 68000 (os3-68000)
  • AmigaOS 4 (os4)
  • MorphOS (mos)
  • AROS i386 (i386-aros)
  • AROS x86_64 (x86_64-aros)
  • AROS aarch64 (aarch64-aros)

Verification

Runtime checks ran on the A4000 OS 3.2 Amiberry config (68060, ZZ9000 RTG, icon.library 51.4), with Opus on its own native screen.

  • Environment reloads: 12 command LoadEnvironment calls 3 s apart, alternating PAL and PAL laced. HEAD hit a Software Failure within 4–6 loads. This branch got through all 12 in three runs; Opus settled on the last environment loaded (dopus screen 640x256) with its listers open and still answered ARexx.
  • Quit with loads queued: six loads queued 1 s apart, then command quit force. The DOPUS.1 port was gone after 3 s and the system was back at Workbench with no requester.
  • Status pop-up: with guest input events, opened the pop-up on a name-mode lister, went to View As → Icon and released. The sub-menu showed Name checked, and lister query mode changed from name to icon.
  • Icon images: hide/reveal cycles and environment reloads with a lister toolbar that uses an OS 3.5 .info image redrew the toolbar each time, with no crash. icon.library 51.4 does not show whether pens are released, so the pen fix itself is checked only by code inspection.
  • Screen Mode / Sounds first page: not exercised at runtime. In English the first page is Backgrounds, and this checkout ships no catalog that sorts either page first.
  • Builds: dopus5.library, DirectoryOpus and configopus.module for OS3 (pinned CI image), OS4, MorphOS and AROS x86_64 have the same warning counts as HEAD.

Checklist

  • CI is green (or expected failures are explained).
  • ChangeLog updated with a [dopus5 next] entry.
  • documents/DOpus5.guide updated and @$VER bumped if user-visible
    behaviour changed.
  • Relevant *_REVISION in source/Include/dopus/version.h bumped if
    a versioned binary changed. (Left for the release.)
  • No new compiler warnings introduced on any platform.
  • No drive-by reformatting of unrelated code.

…ing screen

LoadEnvironment replies before the load is done, so scripts could
start a second environment process while the first was still in
environment_open(). Both freed the same button banks and Opus
crashed (Software Failure 0100000F in dopus_environment).

- environment_proc holds env_load_lock until the display it closed
  is open again; loads run one at a time, in order.
- environment_open() swaps the lister menu, user menu and scripts
  banks under their locks, as main_reset does.
- GUI->pattern_lock is initialised and used: close_display() holds it
  until the patterns are freed and the screen is closed, and
  display_get_pattern() holds it except across display_update_pattern()
  and gives up once the screen has gone.
…oses

Toolbar and button images loaded from .info files stayed laid out on
the screen after their last remap was freed, so after a screen mode
change the next LayoutIcon() or the final FreeDiskObject() released
pens through the closed screen (reported by Peter Keunecke).

- FreeRemapImage() undoes the icon layout when the last remap goes;
  loading such an image no longer leaves it laid out on the default
  public screen.
- A lister's own toolbar frees its cache, image remaps and pens with
  the window and rebuilds them when the window opens.
- ARexx AppIcons free their remap before the icon is freed.
…n open

- The lister status pop-up (SRCE/DEST/OFF) has the View As sub-menu
  (Name, Icon, Icon Action, Show All), shared with the window's
  right-button pop-up. A name-mode lister too large to move the pointer
  outside of could not change its view (reported by Peter Keunecke).
- The Environment editor builds its screen mode list before the window
  opens. In languages where Screen Mode sorts first, the first page
  stayed empty until another page was picked (reported by Peter
  Keunecke).
@midwan midwan changed the title fix: back-to-back environment loads and screen mode changes no longer crash or leak pens fix: safe back-to-back environment loads and screen mode changes Oct 21, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T06:54:57.292132Z 433cba3 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0826adbc87

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread source/Program/display_pattern.c Resolved
- Reject pattern work after a display generation changes
A pattern process that let go of pattern_lock across
display_update_pattern() gave up when the display it was loading for
had been closed. If the next display was already open by then,
display_open() had left the pictures to that process, so the new
screen came up without its backdrop. It now starts the load again for
the open display. The generation is also bumped when only the window
closes and its patterns are freed, not just when the screen closes.
@midwan

midwan commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0c1f2d9800

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread source/Program/environment.c Resolved
Comment thread source/Program/lister_window.c Resolved
A load waiting for env_load_lock could not see IPC_QUIT, so quitting
while loads were queued left close_display() waiting in IPC_ListQuit()
for a process that waited for the running load, which in turn waited
for the main process to reopen the display. Loads now queue with
Procure(), in order, and leave when signalled to quit; the running
load skips reopening the display once Opus is quitting.
… opens

lister_new_toolbar() built the cache, remaps and pens of a custom
toolbar on the current screen even for an iconified lister, and a
screen mode change left them there because only a lister with a
window frees them. Without a window it now keeps no cache;
lister_open_window() builds it on the screen it opens on.
The sound list is built after the window opens (its pens come from the
window), so a Sounds page that sorts first in the translated list came
up empty. The page is set up again once the list exists.
@midwan

midwan commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 931439ef9c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread source/Program/display_pattern.c Resolved
… screen

A pattern process that found the screen gone gave up, but could still
be in the process list when display_open() checked for one, so the
new display came up with no pattern process and no backdrop.
display_get_pattern() now records giving up under pattern_lock, and
display_open() decides under the same lock, starting a new process
when the old one has given up.
@midwan

midwan commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 433cba31f3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@midwan
midwan merged commit 3ccb217 into master Oct 21, 2026
18 checks passed
@midwan
midwan deleted the fix/environment-reload-screenmode branch October 21, 2026 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant