Repository navigation
Conversation
A timed-out build only interrupted its task, and no render loop looked at the interrupt flag, so the work ran to completion, kept its memory and was still written to the cache. Builds also ran on an unbounded executor. - Add RenderCancellation.check() and call it once per frame, line or item in the tooltip, inventory, container, HUD, scene, glint, composite and GIF encoding loops. - Skip the cache write for a render that finished after cancellation. - Limit concurrent builds with a fair semaphore (image.generator.maxConcurrentRenders, default max(2, CPUs)); a build that cannot get a slot within the timeout fails. Nested builds reuse their parent's slot. - Throw GeneratorTimeoutException on timeout and cancel the task when the waiting caller is interrupted.
Both branches add an import and a check at the same render loops; the only conflicts were the adjacent import lines.
Aerhhh
changed the base branch from
master
to
security/input-clamps-pixel-budget
November 21, 2026 02:02
Owner
Author
|
This now sits on top of #116: both changes add a line at the same render loops, so I merged #116's branch into this one (the only conflicts were adjacent import lines) and pointed this PR at that branch. Merge #116 first; GitHub will retarget this PR to |
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.
Why
Follow-up to the security review (see #116).
GeneratorImageBuilder.build()cancelled its task on timeout, but no render loop checked the interrupt flag, so a timed-out render ran to completion, held its memory, and was still written to the cache. Builds also ran on an unbounded virtual-thread executor, so an attacker could stack as many of these as they could send.What changed
RenderCancellation.check()(new) is called once per frame, line or item in the tooltip, inventory, container, HUD, scene, glint, composite and GIF-encoding loops. A cancelled render now ends at its next check withGeneratorTimeoutException.Generator.generatechecks betweenrenderand the cache put.image.generator.maxConcurrentRenderssets it (defaultmax(2, CPUs), read once at class load). A build that cannot get a slot within the timeout fails withGeneratorTimeoutException. The slot is released by the render task, not the waiting caller, so a render still winding down keeps counting. A build started from inside a render reuses its parent's slot.build()now throwsGeneratorTimeoutException(aGeneratorException, same message) on timeout, and cancels the task if the waiting caller is interrupted.Behaviour changes to be aware of
ImageUtil.toGifBytes, JDK image I/O) still run until that call returns.Not in this PR
NBT and scene parsing still run on the caller's thread before
build(), outside the timeout. Moving them is an API change; their cost is bounded separately (#116 and the parser follow-up).Testing
GeneratorImageBuilderTimeoutTest(3 tests): a spinning render is stopped by the timeout, a render that finishes after cancellation is not cached, and a nested build completes.DisplayToolTest.enchantedRenderIsAnimatedhitting the 20 s render timeout on a loaded local machine; it fails the same way on unmodifiedmasterthere and passed in CI on Bound untrusted render input with clamps and a shared pixel budget #116. The full suite was not run locally.