Repository navigation
fix: leave later system patches in place when dopus5.library closes - #233
Merged
Merged
Conversation
WB_Remove_Patch() wrote the saved vectors back without checking them, so patches another program installed after Opus were thrown out. With Sysmon's SysInfo.library (opened by the clock task) this left sysmon.library half installed, and the machine hung soon after Opus quit (#231). Patch state now lives in static arrays outside LibData. Removal turns every patch into a pass-through, waits for running calls, and restores only vectors that still point to Opus; a vector patched again keeps its foreign patch and Opus stays in the chain. The library refuses to expunge while such a patch remains, and the next Opus start switches it back on. The Original*() DOS/icon calls use the system function when the patches are not running (with dopus/NoSysPatch they read an unallocated table), and the OS4 OpenWorkbenchObject() patch returns its result.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Quitting Opus no longer throws out system patches that other programs installed after it. Until now, with Sysmon's SysInfo.library on the system, the machine could freeze or reboot soon after Opus quit. dopus5.library now restores only the vectors that still point to it, and leaves its own function in a chain someone else has patched since, passing calls through.
Issue
Fixes #231
The freeze in the original report was a stack overflow in aatext.library, fixed in aatext.library 1.1. While tracking it down, the AAText author found this second problem:
L_WB_Remove_Patch()wrote the saved vectors back without checking them.Changes
wb_old_function,wb_patch_base,wb_patch_flags) moves out of LibData into static arrays, because a patch left in a chain must keep working after the library data is freed. Every patch function starts with a check: when Opus is not running the patch, the call goes straight to the next function and touches no library data. Removal switches the patches off, waits onusecountfor calls already running inside them, and only then changes vectors.LibExpunge/LibCloserefuse to unload the segment whilewb_patches_installed()is true. The next Opus start reuses the resident library and switches the patch back on instead of installing it a second time. In that case a newer dopus5.library on disk only loads after a reboot.Original*()without patches.OriginalOpen()and the other DOS/icon bypass calls use the plain system function when the patch is not running. Withdopus/NoSysPatchset,OriginalRelabel(),DeleteIcon(), andWriteIcon()before icon.library V44, read a patch table that was never allocated.OpenWorkbenchObject()patch returned FALSE even when the object was opened.#elseremoval branch is gone; its "reinstall" path setold_function[]instead of the patch.The atomic
usecounthelpers move from three copies intowb.hand gain a compiler barrier on OS3, so the patch state is read after the count goes up. The revision bump is left to the release, as in recent PRs.Affected platforms
os3)os3-68000)os4)mos)i386-aros)x86_64-aros)aarch64-aros)Verification
Runtime checks ran on the A4000 OS 3.2 Amiberry config (68060), with Sysmon 1.20a's SysInfo.library and a probe that dumps exec LVOs -30 to -330 and classifies each vector as ROM, dopus5.library or sysmon.library. The script started Opus, quit it with
command quit force, calledRemLibrary()on dopus5.library, opened bullet and TrueType fonts, then started and quit Opus a second time.RemLibrary()dopus5.libraryfor OS3 (pinned CI image), OS4, MorphOS and AROS i386/x86_64/aarch64. No new warnings againstmaster; MorphOS has 6 fewer (_ATOMIC_ADDpointer sign).Checklist
ChangeLogupdated with a[dopus5 next]entry.documents/DOpus5.guideupdated and@$VERbumped if user-visiblebehaviour changed. (No documented behaviour changes.)
*_REVISIONinsource/Include/dopus/version.hbumped ifa versioned binary changed. (Left for the release.)